Reputation: 4789
I have a bunch of files in a directory. The file names are created like this: a_dc.ac.txt, a_dc.aa.txt, a_dc.cc.txt and so on. I need to replace all the a_dc portion of the names to a_adj. I tried the following but it's not working:
rename 's/a_dc/a_adj/s' *
Is there any other way to fix this? I am not sure why rename is not working.
P.S. I am using centos
Upvotes: 2
Views: 266
Reputation: 784878
Using find one-liner:
find . -maxdepth 1 -name 'a_dc.*.txt' -exec bash -c 'x="{}"; mv "$x" "a_adj.${x#*.*.}"' \;
Upvotes: 3