Renaming files – Adding a suffix to the file name
Posted on October 23rd, 2009 in Web Development | 1 Comment »
The solution provided in Easily Renaming Multiple Files works perfectly well if we want to add a prefix to a file. This solution does not work too well if you want to add a suffix.
Objective: For all jpegs in a folder add the suffix _tn after the file name and before the extension.
Example: file1.jpg = file1_tn.jpg
In the console type the following:
for i in *.jpg ; do mv $i `echo $i | sed 's/\.jpg/\_tn.jpg/'` ; done
If the file name was in CAPS and and you’d rather have your file name in lowercase pipe the following on:
for i in *.jpg ; do mv $i `echo $i | sed 's/\.jpg/\_tn.jpg/' | tr [:upper:] [:lower:]` ; done
One Response
[...] This works well for adding a prefix to files in a folder. To add a suffix to a file read “Renaming files – Adding a suffix to the file name” [...]