快速查找文件夹中非Universal文件

2022-11-23 16:10:03
标签: applescript lipo arm64 applesilicon

   在AppleSilicon上做功能,需要检查同事提供的binary是否已经支持Universal,需要x86_64和arm64,于是,做成Automator的Service,在Finder中选中文件夹的时候显示菜单。

这个Automator运行苹果脚本

tell application "Finder"

set selectedItems to selection as alias list

if selectedItems is {} then return

set firstFile to quoted form of POSIX path of (item 1 of selectedItems)

set machoFiles to do shell script "export NCPU=`sysctl -n hw.physicalcpu`;cd " & firstFile & ";find . -type f -print0 | xargs -P $NCPU -0 -L1 file | grep -v -E \"for architecture\" | grep -E \"Mach-O .*\" | cut -d \":\" -f1 | grep -v -E \"(x86_64]|arm64])\""

tell application "Terminal"

activate

set currentTab to do script ("cd " & firstFile)

end tell

set machoFileLists to every paragraph of machoFiles

repeat with machoFile in machoFileLists

set file_type to do shell script "cd " & firstFile & ";lipo -archs " & machoFile

set file_type_list to every word of file_type

if (file_type_list does not contain "x86_64") or (file_type_list does not contain "arm64") then

log machoFile

log file_type

tell application "Terminal"

activate

do script ("lipo -archs " & machoFile ) in currentTab

end tell

end if

end repeat

end tell

 

 

阅读(0) 收藏(0) 转载(0) 举报/Report
相关阅读

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有