Replace text in folder names
- by dannyb
How can I replace the same text in folder names in linux?
Say I have "Photos_Jun", "Photos_July", "Photos_Aug", etc. whats the simplest way I can rename them like "Photos Jun", "Photos July", etc (basically I want to replace the underscore with a space " ". I have about 200 of these folders.
I was looking at solution: http://stackoverflow.com/questions/1836563/how-can-i-easily-bulk-rename-files-with-perl
It looks like what im looking for however, I dont know how to make a regular expression to match folders that are alphanumeric followed by a "_".
All files have non-numeric names, so I think [a-zA-Z] is the right way to start.
perl -e 'foreach $f (glob("File\\ Name*")) { $nf = $f; $nf =~ s/(\d+)$/sprintf("%03d",$1)/e; print `mv \"$f\" \"$nf\"`;}'
Thanks for any help!