首页 > 系统服务 > 详细

MacOS copy图标shell脚本

时间:2015-06-05 22:25:07      阅读:296      评论:0      收藏:0      [点我收藏+]

不会shell  同学做的...

可以看见在当前文件夹下创建了一个icons文件夹

最后还压缩了文件夹

#!/bin/bash

# readPlist [plist] [key]
function readPlist() {
    plist=$1
    key=$2

    value=`plutil -p "$plist" | grep $key | awk -F => {print $2} | sed -e s/\"//g`
    echo $value
}

# copyAppIcon [app] [dir]
function copyAppIcon() {
    apath=$1
    iDir=$2
    appName="${apath##*/}"

    if [ -d "$apath" ]; then
        icon=`readPlist "$apath/Contents/Info.plist" "CFBundleIconFile"`
        if [ "${icon##*.}" != "icns" ]; then
            icon="$icon".icns
        fi

        cp "$apath/Contents/Resources/$icon" "$iDir/$appName.icns"
    fi
}

iconDir="icons"
mkdir $iconDir
mkdir $iconDir/Applications
mkdir $iconDir/UtilitiesÅ

for app in /Applications/*
do
    if [ "$app" != "/Applications/Utilities" ]; then
        copyAppIcon "$app" $iconDir/Applications
    fi
done

for app in /Applications/Utilities/*
do
    copyAppIcon "$app" $iconDir/Utilities
done

echo "[*] copy icons done"
zip -rq icons.zip $iconDir/*
echo "[*] compresses the folder done"
rm -r $iconDir
echo "[*] del icons folder done"

 

MacOS copy图标shell脚本

原文:http://www.cnblogs.com/cart55free99/p/4555658.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!