( @ARGV ) || die "Usage : $0 /some/directory /another/directory\n"; foreach $directory ( @ARGV ) { if ( -d $directory ) { chdir("$directory"); convert_dir(); chdir("-"); } } sub convert_dir { chomp( my $dir = `pwd`); opendir(DIR,"$dir"); while ( my $file = readdir DIR ) { my $oldname = "$file"; $file =~ s/\s+/_/g; # print "Renaming $oldname to $file\n"; rename("$oldname","$file"); } close(DIR); return 1; } ___ | | | x | <---bang head here if this |___| frustrates you