Batch rename in OSX, add @2x to all files ending with .png
With the help of Mark Setchell's answer I was able to solve this with the following one-liner:
for f in *.png; do NEW=${f%.png}@2x.png; mv ${f} "${NEW}"; done;
Edit: flopr was right, should work now
Let me add something to the contribution. A more generic, multiple format (jpg, png, ..) and name "extension free" (pattern < name >@2x.< extension> ) one lined solution would be this:
for file in *; do mv "$file" "${file%.*}@2x.${file##*.}"; done
This works like a charm. Hope it helps
This should do it:
#!/bin/bash
ls *.png | while read f
do
BASE=${f%.png} # Strip ".png" off end
NEW=${BASE}@2x.png # Add in @2
echo mv "$f" "${NEW}" # Rename
done
Save it in a file called Add2x, then type:
chmod +x Add2x
./Add2x
When you have seen what it is going to do, remove the word "echo" so it actually does it.