開(kāi)發(fā)腳本分享(automator, shell)

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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容