1234567891011121314151617181920
#!/bin/bashjson_file="/Users/fang/Lab/Shell/xcassets/Contents.json"orig_path="/Users/fang/Lab/Shell/xcassets/images"dest_path="/Users/fang/Lab/iOS/TestProject/Images.xcassets"imgs=`find $orig_path -name "*@2x.*"`for img in $imgs; do filename=`basename $img` img_name="${filename%@*}" folder="$dest_path/$img_name.imageset" if [ ! -d $folder ]; then mkdir $folder fi cp -r $img $folder cp -r $json_file $folder sed -e 's/\$FILE_NAME/'$img_name'/g' $json_file > "$folder/Contents.json"done
123456789101112131415161718192021
{ "images" : [ { "idiom" : "universal", "scale" : "1x" }, { "idiom" : "universal", "scale" : "2x", "filename" : "$FILE_NAME@2x.png" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" }}