jrottman
Programmer
- Jun 17, 2005
- 47
I know it is possible to search a string and determine whether or not the string has the regexp with in the string.
What I am trying to accomplish is renaming of files that have either non-standard or illegal chars with in the file name, but still retain the file extension.
IE
If I were to get this file 12(1)test.txt, I would like to rename it to 121test.txt.
With in coldfusion or java, I would using something like reFind(regExp,file) and if determined to have illegal chars rename file.
This is the standard regExp that I use with in cf/java as white list chars. A-Za-z0-9.-_.
Everything I have tried has pretty much come up with nada.
Can someone point me in the right direction.
This is my current code.
#! Scrubs illegal chars from document names
sub scrubDoc {
foreach (@_){
print "$_";
rename("$_" , "/^A-Za-z0-9.-_/");
}
}
What I am trying to accomplish is renaming of files that have either non-standard or illegal chars with in the file name, but still retain the file extension.
IE
If I were to get this file 12(1)test.txt, I would like to rename it to 121test.txt.
With in coldfusion or java, I would using something like reFind(regExp,file) and if determined to have illegal chars rename file.
This is the standard regExp that I use with in cf/java as white list chars. A-Za-z0-9.-_.
Everything I have tried has pretty much come up with nada.
Can someone point me in the right direction.
This is my current code.
#! Scrubs illegal chars from document names
sub scrubDoc {
foreach (@_){
print "$_";
rename("$_" , "/^A-Za-z0-9.-_/");
}
}