Created
December 2, 2016 03:13
-
-
Save hoshi-takanori/f4346aaa02ec090c5ae149bc5c6053b2 to your computer and use it in GitHub Desktop.
Rename xcode image assets.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
old="$1" | |
new="$2" | |
if [ "x" = "x$old" -o "x" = "x$new" ] | |
then | |
echo "usage $0 old new" | |
exit 2 | |
fi | |
dir=`dirname "$old"` | |
old=`basename "$old" .imageset` | |
new=`basename "$new" .imageset` | |
src="$dir/$old.imageset" | |
dst="$dir/$new.imageset" | |
if [ ! -d "$src" ] | |
then | |
echo "$src: src not exists" | |
exit 1 | |
fi | |
if [ -x "$dst" ] | |
then | |
echo "$dst: dst exists" | |
exit 1 | |
fi | |
(cat "$src/Contents.json" ; echo) | sed "s/$old/$new/" | perl -pe "chomp if eof" > "$src/Contents.json.new" | |
diff "$src/Contents.json" "$src/Contents.json.new" | |
mv "$src/Contents.json.new" "$src/Contents.json" | |
for ext in ".png" "@2x.png" "@3x.png" | |
do | |
mv "$src/$old$ext" "$src/$new$ext" | |
done | |
mv "$src" "$dst" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment