質問

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.

役に立ちましたか?

解決

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
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top