I have a large number of files in a directory structure I want to rename.
The file names are in this format:
"aaaaaa-bbbbbb_cccccc-ddddd_eeeee-fffff-ggggg-hhhhh.psd"
I want them in this format:
"Aaaaaa-Bbbbbb_Cccccc-Ddddd_Eeeee-Fffff-Ggggg-Hhhhh.psd
A single find and sed routine should transform them into the correct format:
find . -name "*psd" -exec sh -c "echo 'cp '{} `echo {} | sed 's/\([_-][a-z]\)\([A-Z]*\)/\2\U\1/g'`" \;
But it doesn't work:
input:
Assisted-or-Auto/Abstract-Render/assisted-or-auto_abstract-render_tiny-bubbles3.psd
output:
cp ./Assisted-or-Auto/Abstract-Render/assisted-or-auto_abstract-render_tiny-bubbles3.psd ./Assisted-or-Auto/Abstract-Render/assisted-or-auto_abstract-render_tiny-bubbles3.psd
The sed routine works if I remove the backtick and insert a semi-colon.
find . -name "*bubbles3.psd" -exec sh -c "echo 'cp '{} ; echo {} | sed 's/\([_-][a-z]\([A-Z]*\)/\2\U\1/g'" \;
cp ./Assisted-or-Auto/Abstract-Render/assisted-or-auto_abstract-render_tiny-bubbles3.psd
./Assisted-Or-Auto/Abstract-Render/assisted-Or-Auto_Abstract-Render_Tiny-Bubbles3.psd
So, for some reason backtick is not do what it should be doing. Any ideas on how I can resolve this issue? fyi replacing backticks with the " $(cmd) " notation has the same effect
Thanks