So for some reason, a client of ours decided to use characters like < in file names. I'm writing a script to recursively change instances of < to _ throughout the file system but I'm running into a problem.
Here's what I have so far:
find . -type f -name "*\<*" -exec bash -c 'mv -v $0 ${0/\</_}' {} \;
This only alters the first instance of <. So for a file with x instances of < in its name, I would have to run the script x times. I'm pretty sure I need a loop to accomplish what I'm looking for but I can't seem to get it working.
An example for clarity's sake:
filename<T1<2015.pdf
I run the above command and end up with this file name:
filename_T1<2015.pdf
I want a command that will change it to this in one pass:
filename_T1_2015.pdf
Any tips?
[link][9 comments]