You are not logged in.
Hi,
I've used this script before without issues (Prior to macOS Catalina), now I am getting " error "Can’t get dimensions of missing value." number -1728 from «class dmns» of missing value "
How can this be corrected?
Thanks for your time and experience
tell application "Finder"
set theFolder to choose folder
if not (exists folder "Portrait" in folder theFolder) then
make new folder in folder theFolder with properties {name:"Portrait"}
end if
if not (exists folder "Landscape" in folder theFolder) then
make new folder in folder theFolder with properties {name:"Landscape"}
end if
set fileList to document files of theFolder
end tell
tell application "Image Events"
launch
repeat with theFile in fileList
set theImage to open theFile as alias
copy the dimensions of theImage to {Horiz, Vert}
close theImage
if Horiz is greater than Vert then
-- landscape
tell application "Finder"
move theFile to folder "Landscape" of folder theFolder
end tell
else
-- portrait
tell application "Finder"
move theFile to folder "Portrait" of folder theFolder
end tell
end if
end repeat
end tell
Offline
I've included my suggestion below. I tested the script on Monterey and it worked as expected.
Applescript:
set theExtensions to {"png", "tiff"} -- edit as desired but digital photos may not sort correctly
set theFolder to (choose folder) as text
set landscapeFolder to (theFolder & "Landscape:")
set portraitFolder to (theFolder & "Portrait:")
tell application "Finder"
if not (exists folder portraitFolder) then make new folder in folder theFolder with properties {name:"Portrait"}
if not (exists folder landscapeFolder) then make new folder in folder theFolder with properties {name:"Landscape"}
set fileList to (every file in folder theFolder whose name extension is in theExtensions) as alias list
end tell
tell application "Image Events"
launch
repeat with theFile in fileList
set theImage to open theFile
set {Horiz, Vert} to dimensions of theImage
close theImage
if Horiz is greater than Vert then
my moveFile(theFile, landscapeFolder)
else
my moveFile(theFile, portraitFolder)
end if
end repeat
end tell
on moveFile(theFile, theFolder)
try
tell application "Finder" to move theFile to folder theFolder
on error
tell application "Finder" to set fileName to name of theFile
display alert "A file already exists in the target folder" message fileName buttons {"Skip"}
end try
end moveFile
Last edited by peavine (2022-06-06 10:06:57 am)
2018 Mac mini - macOS Monterey - Script Debugger 8
Offline
SAAWEEET! Thank you soooo much!! You saved my hide!
Offline