jcadima
2/15/2019 - 7:30 AM

Rename files with sed



https://stackoverflow.com/questions/1500204/how-do-i-remove-specific-characters-from-file-names-using-bash

Cases
file1-min.jpg
file2-min.jpg
file3-min.png
file4-min.png

# remove "-min" from all files that share this pattern and end with a file extension
for i in *-min.*
do
    mv "$i" "`echo $i | sed 's/-min//'`"
done

# remove "-min" from all files that end in .jpg
for i in *-min.jpg
do
    mv "$i" "`echo $i | sed 's/-min//'`"
done