1.生成babybus 常用圖標(biāo):
#!/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_打包工具專(zhuān)用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}
sips -Z ${sizes[$i]} $f -o ${newdir}/${sizen[$i]}.png
done
done
2.app快速打包成ipa包(用于測(cè)試未重簽名)
#!/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
fi
fi
done
}
scaleHalf(){
fratio=2
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=$[width/fratio]
heightfratio=$[height/fratio]
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.批量根據(jù)文件夾重命名圖片
#!/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.專(zhuān)用復(fù)制文件路徑:
#!/bin/bash
OLDIFS="$IFS"
IFS=$'\n'
while read f ;
do
newdir=${f#*/res/img/x[0-9]/}
echo $newdir
done

automator截圖.png
Workflows下載:
鏈接: http://pan.baidu.com/s/1slcfsFr 密碼: 7k87