r/applescript • u/bigdrunk • Aug 31 '21
Error when moving files
Hi all, I am trying to update an AppleScript that has been running on macOS 10.12 but is not playing in macSO 11.5
The script uses InDesign Server to create two PDF files from an InDesign artwork that is dropped into a hot folder. Once they are created they are then filed to a location based on their filename (group, week number) - all seems well until its time to move the file, that's when I get the result below.
Im hoping its something simple that has changed between the two OS versions?
tell application "System Events"
exists process "ExpanDrive"
exists process "FontExplorer X Pro"
end tell
tell current application
do shell script "/bin/ls /Volumes"
end tell
tell application "Finder"
get every file of folder "ServerSSD:Users:admin:Documents:PDF:Hotfolders:Hotfolder-1-NoPrint:"
get name of alias "ServerSSD:Users:admin:Documents:PDF:HotFolders:Hotfolder-1-NoPrint:DCG369~3962_100_009692_00_80x1400.indd"
end tell
tell current application
info for alias "ServerSSD:Users:admin:Documents:PDF:HotFolders:Hotfolder-1-NoPrint:DCG369~3962_100_009692_00_80x1400.indd" given «class Krtn»:{name:"Nm", name extension:"Ex"}
end tell
tell application "Finder"
get every file of folder "ServerSSD:Users:admin:Documents:PDF:Hotfolders:Hotfolder-1-NoPrint:"
end tell
tell current application
info for alias "ServerSSD:Users:admin:Documents:PDF:HotFolders:Hotfolder-1-NoPrint:DCG369~3962_100_009692_00_80x1400.indd" with size
info for alias "ServerSSD:Users:admin:Documents:PDF:HotFolders:Hotfolder-1-NoPrint:DCG369~3962_100_009692_00_80x1400.indd" with size
end tell
tell application "Finder"
get name extension of alias "ServerSSD:Users:admin:Documents:PDF:HotFolders:Hotfolder-1-NoPrint:DCG369~3962_100_009692_00_80x1400.indd"
end tell
tell application "InDesignServer"
open alias "ServerSSD:Users:admin:Documents:PDF:HotFolders:Hotfolder-1-NoPrint:DCG369~3962_100_009692_00_80x1400.indd"
end tell
tell application "Finder"
get name of alias "ServerSSD:Users:admin:Documents:PDF:HotFolders:Hotfolder-1-NoPrint:DCG369~3962_100_009692_00_80x1400.indd"
end tell
tell application "InDesignServer"
export document 1 format PDF type to "/Users/admin/Documents/PDF/DistillerResources/lowHolding/DCG369~3962_100_009692_00_80x1400.pdf" using PDF export preset "[VC-CoolTick]"
end tell
tell application "Finder"
get file 1 of folder "ServerSSD:Users:admin:Documents:PDF:DistillerResources:lowHolding:"
get document file "DCG369~3962_100_009692_00_80x1400.pdf" of folder "lowHolding" of folder "DistillerResources" of folder "PDF" of folder "Documents" of folder "admin" of folder "Users" of startup disk
end tell
tell current application
info for alias "ServerSSD:Users:admin:Documents:PDF:DistillerResources:lowHolding:DCG369~3962_100_009692_00_80x1400.pdf" with size
info for alias "ServerSSD:Users:admin:Documents:PDF:DistillerResources:lowHolding:DCG369~3962_100_009692_00_80x1400.pdf" with size
info for alias "ServerSSD:Users:admin:Documents:PDF:DistillerResources:lowHolding:DCG369~3962_100_009692_00_80x1400.pdf" given «class Krtn»:{name:"Nm", name extension:"Ex"}
end tell
tell application "Finder"
set name of alias "ServerSSD:Users:admin:Documents:PDF:DistillerResources:lowHolding:DCG369~3962_100_009692_00_80x1400.pdf" to "DCG369~3962_100_009692_00_80x1400_LR.pdf"
end tell
tell current application
do shell script "/bin/mv -f '/Users/admin/Documents/PDF/DistillerResources/lowHolding/DCG369~3962_100_009692_00_80x1400.pdf' 'Volumes/POS_LR/'Week00/1*/"
end tell
tell application "Finder"
move alias "ServerSSD:Users:admin:Documents:PDF:DistillerResources:lowHolding:DCG369~3962_100_009692_00_80x1400.pdf" to folder "ServerSSD:Users:admin:Documents:PDF:FailedJobs-1:" with replacing
Result:
error "Finder got an error: Handler can’t handle objects of this class." number -10010
1
u/bigdrunk Sep 02 '21
It seems that the script fails when its time to rename the file. Once it has the _LR at the end, the script is told to use that new filename to refer to the file.
This command was working in 10.12. It doesn't error while running. Just doesn't rename the file, hence when it tries to do something it thinks the file is missing.
set name of alias "ServerSSD:Users:admin:Documents:PDF:DistillerResources:lowHolding:DCG369~3962_100_009692_00_80x1400.pdf" to "DCG369~3962_100_009692_00_80x1400_LR.pdf"
move alias "/Users/admin/Documents/PDF/DistillerResources/lowHolding/DCG369~3962_100_009692_00_80x1400.pdf" to folder "ServerSSD:Users:admin:Documents:PDF:FailedJobs-1:" with replacing
1
u/copperdomebodha Aug 31 '21
I'm reading through this on my machine and other than the facet that I don't have and can't get "InDesignServer", so here this script cannot...
or
Other than those two commands, it appears that the majority of this script does not have any action actually happening.
None of the "get" and "info for" commands are assigning the results to any variables or acting on the results directly. They do nothing.
This end portion of the script should cause three actions...
But it looks to me like 'set name of ' changes the filename of 'DCG369~3962_100_009692_00_80x1400.pdf' to 'DCG369~3962_100_009692_00_80x1400_LR.pdf' but then the subsequent line tries to move the un-renamed file to a new location.
All very confusing mixing shell commands and paths with aliases and finder file actions. I'd try to consistently use finder commands. They return references you can re-use easliy.
Can you clarify what this script is supposed to do step-by-step? I suspect that it can be greatly shortened, simplified and made to be reliable and easily maintainable.
These lines appear to have functionality. I'v commented ( using -->) what I see these lines actions to be.
1
u/copperdomebodha Sep 17 '21
Ok, so it’s running through all steps but doesn’t open any files? I would expect it to fail at moving the originals for sure. That part is not completed. I would have expected it to open the files though.
We need to look at the errorList to see what it’s failing at.
Append “&return&errorlist” to the display dialog statement in the displayResults handler just after “seconds.” And before the following parentheses.
That should display the errors encountered.
1
u/copperdomebodha Sep 14 '21
Sorry, had to go out of town for business and was fully occupied. Back now. I got you when I get home.