Skip to content

Instantly share code, notes, and snippets.

@schmidt9
Last active March 6, 2019 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schmidt9/7e4f97400d1514a83293a11ae54c51b7 to your computer and use it in GitHub Desktop.
Save schmidt9/7e4f97400d1514a83293a11ae54c51b7 to your computer and use it in GitHub Desktop.
Rename iOS splash screen files
#!/bin/sh
echo "path: $1"
#check number of args
if [ $# = 0 ]; then
echo "No path to images directory"
exit 1
fi
for filename in "$1"/*.png; do
echo "file: $filename"
pixelWidth=$(sips -g pixelWidth "$filename" | awk '/pixelWidth:/{print $2}')
pixelHeight=$(sips -g pixelHeight "$filename" | awk '/pixelHeight:/{print $2}')
echo "size: $pixelWidth x $pixelHeight"
if [[ $pixelWidth = 640 && $pixelHeight = 960 ]]; then
cp "$filename" "$1/Default@2x.png"
elif [[ $pixelWidth = 640 && $pixelHeight = 1136 ]]; then
cp "$filename" "$1/Default-568h@2x.png"
elif [[ $pixelWidth = 828 && $pixelHeight = 1792 ]]; then
cp "$filename" "$1/Default-Portrait-1792h@2x.png"
elif [[ $pixelWidth = 1125 && $pixelHeight = 2436 ]]; then
cp "$filename" "$1/Default-Portrait-2436h@3x.png"
elif [[ $pixelWidth = 1242 && $pixelHeight = 2208 ]]; then
cp "$filename" "$1/Default-Portrait-736h@3x.png"
elif [[ $pixelWidth = 1242 && $pixelHeight = 2688 ]]; then
cp "$filename" "$1/Default-Portrait-2688h@3x.png"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment