Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash script/command to bulk remove "@2x" from filename (retina image -> normal)

Tags:

bash

rename

mv

bulk

How do I rename a bulk of files in a bash command or script, to remove iOS's retina indicator (@2x)?

I've already resized them, but the resize software isn't smart on renaming the output file.

like image 792
Kof Avatar asked Jul 05 '13 08:07

Kof


1 Answers

Bash offers substitution using the ${var/} syntax. Example: ${i/AAAA/BBBB} replaces AAAA occurrences in $i with BBBB. Therefore loop over all files matching *@2x.* and rename each one.

for i in *@2x.*; do
    mv "$i" "${i/@2x/}"
done
like image 65
Kof Avatar answered Sep 28 '22 15:09

Kof