1.生成babybus 常用图标:
#!/bin/bash
sizes=(72 144 76 152 57 114 120 512)
sizen=("Icon-72" "Icon-72@2x" "Icon-76" "Icon-76@2x" "Icon" "Icon@2x" "Icon-120" "00_打包工具专用Icon-512")
OLDIFS="$IFS"
IFS=$'\n'
while read f ;
dir=${f%/*}
dirname="cutimg"
newdir=$dir/$dirname
mkdir ${newdir}
do
for i in "${!sizes[@]}"; do
#sips -Z ${sizes[$i]} $f -o ${f/.png/_${sizen[$i]}.png}
#-o改为-out ???10.12???
sips -Z ${sizes[$i]} $f --out ${newdir}/${sizen[$i]}.png
done
done
2.app快速打包成ipa包(用于测试未签名)
#!/bin/bash
OLDIFS="$IFS"
IFS=$'\n'
while read f ;
do
/usr/bin/xcrun -sdk iphoneos PackageApplication -v $f/bbframework.xcarchive/Products/Applications/bbframework.app -o ${f%/*}/bbframework.ipa
done
3.批量缩放50%图片(可以不用脚本)
#!/bin/bash
#同目录下替换原文件
OLDIFS="$IFS"
IFS=$'\n'
result=0
allFiles() {
for file in $1/*
do
if [ -d $file ]; then
allFiles $file
else
if [[ "${file##*.}" = "png" ]];then
scaleHalf $file
id=$[$id+1]
fi
fi
done
}
scaleHalf(){
fratio=0.5
width=$(sips -g pixelWidth $1 | cut -s -d ':' -f 2 | cut -c 2-)
height=$(sips -g pixelHeight $1 | cut -s -d ':' -f 2 | cut -c 2-)
widthfratio=$(echo "scale=0; $width * $fratio" | bc)
heightfratio=$(echo "scale=0; $height * $fratio" | bc)
sips -z $heightfratio $widthfratio $1
}
while read f ;
do
allFiles $f
done
afplay /System/Library/Sounds/Submarine.aiff
osascript -e 'display notification "图片缩小完毕" with title "50% imgs"'
4.批量根据文件夹重命名图片
#!/bin/bash
OLDIFS="$IFS"
IFS=$'\n'
id=1
allFiles() {
for file in $1/*
do
if [ -d $file ]; then
id=1
allFiles $file
else
if [[ "${file##*.}" = "png" ]];then
rename $file
id=$[$id+1]
fi
fi
done
}
rename(){
value=$1
dir=${value%/*}
dirname=${dir##*/}
new=$dir/$dirname$id.${value##*.}
mv $value $new
}
while read f ;
do
allFiles $f
done
afplay /System/Library/Sounds/Submarine.aiff
osascript -e 'display notification "图片重命名完毕" with title "rename"'
5.专用复制文件路径:
#!/bin/bash
OLDIFS="$IFS"
IFS=$'\n'
while read f ;
do
newdir=${f#*/res/img/x[0-9]/}
echo $newdir
done
Workflows下载:
链接: http://pan.baidu.com/s/1slcfsFr 密码: 7k87