How to replace the same text in folder names on Linux?
Say I have Photos_Jun, Photos_July, Photos_Aug, etc. The easiest way to rename them, for example, "Photos Jun", "Photos July", etc. (basically I want to replace the underscore with space "". I have about 200 such folders.
I was looking for a solution: How can I easily rename files using Perl?
It looks like I'm looking, but I donβt know how to make a regular expression to match folders that are alphanumeric and then β_β.
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!
source share