Bash rename multiple files with one command
March 9. 2015 0 Comments
- Posted in:
- General
Ever had the need to correct multiple filenames?
S0501_SomeName
S0502_SomeName
S0503_SomeName
S0504_SomeName
The following command will allow you to replace the substring and insert another string (or just replace it with an empty string) if needed.
for filename in *.m4v; do newname=`echo $filename | sed 's/S05/S04/g'`; mv $filename $newname; done
Which will transform the sample list to:
S0401_SomeName
S0402_SomeName
S0403_SomeName
S0404_SomeName
HTH