Can any one help with my script below please?
Everything works as expected except the “with replacing” line. Sometimes it does it, sometimes it doesn’t which is really weird as I can’t replicate when it does or doesn’t do it. If I remove that line it prompts for the file to replace as you would expect - I don’t want the prompt to appear and just replace the existing.
Additionally the code:
tell application “MakeZipAndMove”
calls an Automator App that creates a zip archive of theDroppedItems folder and copies it to a specific location on my system. I’ve tried to incorporate these actions into the Applescript so it’s all self contained to no avail so, although not the priority, any help with this too would be greatly appreciated.
on open theDroppedItems – drop the sub Artwork folder
tell application “Finder”
set theAi to first item of ((files of (item 1 of theDroppedItems) whose name extension is “ai”) as alias list)
end tell – finds the Illustrator file within the sub Artwork folder
tell application "Adobe Illustrator"
open theAi -- opens the Illustrator file from the sub Artwork folder
tell document 1
do script "RELEASES UPDATE" from "Dave's" -- runs the specific Illustrator action
tell application "Finder"
set f to ":Users:g-uk-tam1-retail-2:Desktop:PDF's:Not Distilled:" as alias
move files of entire contents of f to theDroppedItems with replacing
tell application "MakeZipAndMove"
As I understand it, your action is distilling the file. This is an asynchronous action, and it takes some time to distill the file. Your Finder is moving the folder without checking if the process of distillation of its ai- file is over.
The solution to the problem is:
You need to save the result of distillation to a different file, not the original one. Then the Finder should check if the new file exists (which means that the distillation is complete). Then you can move the distilled result with Finder. This is the only way to make your script stable.
Checking new file existing is simple. Like this:
tell application "Finder"
repeat until POSIX file output_path exists
or, without Finder:
alias output_HFSpath -- distilled file exists?
Sorry KniazidisR, can’t seem to quote your reply… in answer to your post:
The folder “Not Distilled” is kind’ve a red herring - the file doesn’t go through any actions and is just stored in that named folder.
But you have raised an interesting point. When the script activates Illustrator and calls the specific Action there is some “manual” processing going on within Illustrator BEFORE the script should continue on its route. I think I have been lucky in doing the manual processes quickly thus allowing the script to continue correctly, but have purposely delayed my manual process to see what happens - and it’s an issue. So this “checking for file before continuing” is very relevant.
I will look to incorporating this in the script.