Skip to content

Instantly share code, notes, and snippets.

@sam-w
Last active September 7, 2016 06:15
Show Gist options
  • Save sam-w/d105cde3a5f2b888167dc612cbe29544 to your computer and use it in GitHub Desktop.
Save sam-w/d105cde3a5f2b888167dc612cbe29544 to your computer and use it in GitHub Desktop.
#delete the existing images
find '/Users/sam.warner/Domain/domain-ios-app/Resources/Images.xcassets/Loading Spinners/Gray' -name "*.png" -type f -delete
for i in `seq 0 9`; do
#edit Contents.json
sed -i '' "s/\"filename\" :.*@2x.*/\"filename\" : \"spinner-loop_0$i.png\",/g" "/Users/sam.warner/Domain/domain-ios-app/Resources/Images.xcassets/Loading Spinners/Gray/loading-spinner-frame0$i.imageset/Contents.json"
#rename the folder
mv "/Users/sam.warner/Domain/domain-ios-app/Resources/Images.xcassets/Loading Spinners/Gray/loading-spinner-frame0$i.imageset" "/Users/sam.warner/Domain/domain-ios-app/Resources/Images.xcassets/Loading Spinners/Gray/gray-spinner-frame0$i.imageset"
#copy the new images
cp ~/spinner-loop/spinner-loop_0$i.png "/Users/sam.warner/Domain/domain-ios-app/Resources/Images.xcassets/Loading Spinners/Gray/gray-spinner-frame0$i.imageset"
done
#see the first loop, above
for i in `seq 10 52`; do
sed -i '' "s/\"filename\" :.*@2x.*/\"filename\" : \"spinner-loop_$i.png\",/g" "/Users/sam.warner/Domain/domain-ios-app/Resources/Images.xcassets/Loading Spinners/Gray/loading-spinner-frame$i.imageset/Contents.json"
mv "/Users/sam.warner/Domain/domain-ios-app/Resources/Images.xcassets/Loading Spinners/Gray/loading-spinner-frame$i.imageset" "/Users/sam.warner/Domain/domain-ios-app/Resources/Images.xcassets/Loading Spinners/Gray/gray-spinner-frame$i.imageset"
cp ~/spinner-loop/spinner-loop_$i.png "/Users/sam.warner/Domain/domain-ios-app/Resources/Images.xcassets/Loading Spinners/Gray/gray-spinner-frame$i.imageset"
done
#only use this part if you need to remove existing references to @1x and @3x images
find '/Users/sam.warner/Domain/domain-ios-app/Resources/Images.xcassets/Loading Spinners/Gray' -name "*.json" -type f | while read json; do
sed -i '' "/\"filename\" :.*@1x.*/d" "$json"
sed -i '' "/\"filename\" :.*@3x.*/d" "$json"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment