Renaming part of a filename [duplicate]
for file in *.dat ; do mv $file ${file//ABC/XYZ} ; done
No rename
or sed
needed. Just bash parameter expansion.
Something like this will do it. The for
loop may need to be modified depending on which filenames you wish to capture.
for fspec1 in DET01-ABC-5_50-*.dat ; do fspec2=$(echo ${fspec1} | sed 's/-ABC-/-XYZ-/') mv ${fspec1} ${fspec2}done
You should always test these scripts on copies of your data, by the way, and in totally different directories.