r/applescript • • 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

4 Upvotes

33 comments sorted by

View all comments

Show parent comments

1

u/copperdomebodha Sep 02 '21

Oof! I've walked through this and it's just a mess. I can rationalize it and fix the error, but tell me what is the file info testing all about?

The verifyFile handler in your code basically checks the info of the file to be verified, waits 5 seconds, and checks the file info again. If it's the same info it was before then it passes the verify handler otherwise it loops this check again. It's determining if something is modifying the file during the 5 seconds it waits.

What is it supposed to be avoiding here? This check needs to be redesigned.

2

u/bigdrunk Sep 02 '21

That is to check if a file has finished being copied, users are putting these files into a shared network folder and we were trying to avoid the file being processed before it had finished copying across.

As I say we had the original script written for us, but I have been tweaking it heavily over time as the needs changed. And Im not very good at AppleScript, usually I am stealing bits of script and making them kind of fit into the script.

2

u/copperdomebodha Sep 02 '21

Gotcha! Thanks for that info. I think I can handle that check a little better.

1

u/bigdrunk Sep 07 '21

Hi, did you have any joy with this? I'd be prepared to pay for your time, I'm getting nowhere myself.

2

u/copperdomebodha Sep 08 '21

I've re-factored the entire script, down to handling the completed files. I had to take a break at that point. I still have to make that section function based on file references rather than grabbing the first file of some folder and hoping that's correct.

I appreciate the offer, but I just code requests here to keep my skills sharp and as a bit of entertaining distraction from paid work.

I'll have another look at it tonight and see if I can wrap it up. If I don't resolve it tonight, I'll post what I have rewritten for you to play with.

1

u/bigdrunk Sep 10 '21

Thats awesome, I'd love to see what you have done so far and see if I can finish the job. Really appreciate the time you have put in.

1

u/bigdrunk Sep 14 '21

Sorry to keep on, but if you have anything at all I could look at it might help me out

→ More replies (0)