Posts: 118
Threads: 16
Joined: Dec 2003
Reputation:
0
Need to rename some directories with spaces in the names? Here is a little perl script to do just that. You will need to edit the $startpath.
// Begin Script
#!/usr/bin/perl
use File::Find;
$startpath="/path/to/dir";
do {
$flag=0;
find sub {
my $foo=$File::Find::name;
if (-d $foo && $foo=~/ /) {
($foo2=$foo)=~s/ /_/g;
rename($foo, $foo2);
$flag=1;
}
},$startpath;
} until ($flag==0);
exit;
// End Script
Posts: 161
Threads: 48
Joined: Jan 2004
Reputation:
0
sounds like something i could use since i recently converted from windows. what do i do, just paste it into a text file? and then read the text file?
Posts: 118
Threads: 16
Joined: Dec 2003
Reputation:
0
save it as a text file like rename.pl for example, chmod +x rename.pl, ./rename.pl
Posts: 29
Threads: 6
Joined: Dec 2003
Reputation:
0
i swear i posted something in here.. about saving, chmod, and execution for this perl scirpt... hrmmm
morbondu