Could not rename "D:\data\jhopkin\My Documents\Synergy\ccm_wa\ams_test\MatlabSynergy2-jhopkin\MatlabSynergy2\3atsym3testdir" to "D:\data\jhopkin\My Documents\Synergy\ccm_wa\ams_test\MatlabSynergy2-jhopkin\MatlabSynergy2\@testdir": Permission denied at renameDirs.pl line 43. #### if(@ARGV != 3) { displayHelp(); die "Must have three arguments!"; } $from = $ARGV[0]; $to = $ARGV[1]; my $startDir = $ARGV[2]; if(!is_dir($startDir)) { die "$startDir is not a directory!"; } renameRecurse($startDir); sub renameRecurse { my $dirIn = $_[0]; my $file2 = ""; opendir DIR, $dirIn; my @entries = readdir(DIR); close DIR; foreach $file (@entries) { #skip the "." and ".." if($file ne "." && $file ne "..") { if(is_dir("$dirIn\\$file")) { renameRecurse("$dirIn\\$file"); } if(substr($file,0,length($from)) eq $from) { $file2 = $file; $file2 =~ s/$from/$to/; rename "$dirIn\\$file","$dirIn\\$file2" or die "Could not rename \"$dirIn\\$file\" to \"$dirIn\\$file2\": $!"; } } } } sub is_dir() { if ( -d $_[0] ) { return 1; } else { return 0; } } sub displayHelp { print < Will recursively look through startdirectory for directories beginning with . Will rename directory, replacing with . Example: $0 "@" "3ATSYM3" "C:\\change\\my\\at\\symbols" Created by Jesse Hopkins May 13th, 2010 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END }