我想按大小對照片進行分類,廣告最容易按照寬度進行分類。我想獲得寬度大於1919px的圖片並將其放入另一個文件夾中。我用Google搜索了幾個小時,但沒有運氣。如何在Applescript中按寬度排序圖像?
我得到這個錯誤:error "Image Events got an error: Can’t make item 1 of dimensions of image \"1mouwi.jpg\" into type specifier." number -1700 from item 1 of dimensions of image "1mouwi.jpg" to specifier
在item 1
重複循環。有關如何解決這個問題的任何幫助?
我的代碼:
for f in ~/Pictures/DESKTOPS/*; do [[ $(mdls -rn kMDItemPixelWidth "$f") -ge 1920 ]] && mv "$f" ~/Pictures/DESKTOPS_HD/; done
如果mdls
沒有顯示一些圖像的大小,儘量使用ImageMagick或sips
:
set picFolder to alias ":Users:USERNAME:Pictures:DESKTOPS:"
set hdFolder to alias ":Users:USERNAME:Pictures:DESKTOPS_HD:"
tell application "System Events"
set photos1 to path of files of picFolder
set num to count of photos1
set photos to items 2 thru num of photos1
end tell
set hd to {}
repeat with imgPath in photos
set imgAlias to alias imgPath
tell application "Image Events"
set img to open imgPath
set width to item 1 of dimensions of img
if width > 1919.0 then
set end of hd to imgAlias
end if
close img
end tell
end repeat
tell application "Finder"
move hd to hdFolder
end tell
感謝您的優化!我會在稍後嘗試。 – ZuluDeltaNiner
我如何使這個文件夾操作? – ZuluDeltaNiner