Hi all,
I have the below script which works really well - I would like to modify this to make the manual actions simpler.
The folder structure has a main (parent) folder (which is not referenced in my script) that the below referenced “theDroppedItems” (child folder) resides. Currently I have to manually open the parent folder and drag and drop the “theDroppedItems” onto the below script for it to action.
What I want to do is drag the enclosing Parent folder itself and have the script action as below, keeping in mind the “theDroppedItems” is the child folder the script is essentially working on throughout and the Parent folder would not essentially need to be referenced again. I’m not sure how to do this. There is only ever one Adobe Illustrator file within the theDroppedItems folder.
Any help greatly received.
on open theDroppedItems
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 child Artwork folder
tell application "Adobe Illustrator"
activate
open theAi -- opens the Illustrator file from the sub child Artwork folder
tell document 1
do script "APPROVED RELEASE FILE" from "Dave's" -- runs the specific Illustrator Action (preps for release, outlines, changes approval layer, etc)
end tell
end tell
tell application "Finder"
repeat
try
alias "Dave's Mac:Users:uk:PDF's:Not Distilled:" -- does the distilled file exists? This section checks to see if the new approved PDF has been created and is in the "Not Distilled" folder (where the Illusutrator Action ultimately saves the PDF)
tell application "Finder"
set a to "Dave's Mac:Users:uk:Desktop:PDF's:Not Distilled:" as alias
delay 0.1
duplicate files of entire contents of a to theDroppedItems with replacing
end tell
tell application "MakeZipOnly"
activate
open theDroppedItems
end tell
exit repeat
end try
delay 0.1
delete files of entire contents of a -- this removes the Approved PDF from the Not Distilled folder after it has been "moved" ("move" doesnt seem to move but "copies")
end repeat
-- the above block activates an Automator application to zip file (need to figure out how to do this in Applescript to make this self contained - although all references point to this being incredibly complex - Automator makes this section easy
tell application "Finder"
set a to "Dave's Mac:Users:uk:Desktop:PDF's:Not Distilled:" as alias
set b to "Dave's Mac:Volumes:MacRAID:TEMPORARY FILE TRANSFERS:RELEASES:PDF's:" as alias
move files of entire contents of a to b with replacing
end tell
delay 0.1
delete files of entire contents of a -- this removes the Approved PDF from the Not Distilled folder after it has been "moved" ("move" doesnt seem to move but "copies")
end tell
tell application "Finder"
set NameOfFile to (name of (info for theDroppedItems))
set NameOfFile to text 1 thru ((offset of "." in NameOfFile) - 1) of NameOfFile
set myFile to theDroppedItems as alias
--display dialog NameOfFile
end tell
tell application "Microsoft Outlook"
set mySubject to NameOfFile & " APPROVED FILE RELEASE" as text
set myContent to "<p style=font-family:Calibri>Hi</p><p style=font-family:Calibri>Attached is the Approved Release File for " & NameOfFile & "<p style=font-family:Calibri>Thanks</p>"
set myAttachment to theDroppedItems
set myMsg to make new outgoing message with properties {subject:mySubject, content:myContent}
tell myMsg
make new attachment with properties {file:myFile}
make new recipient with properties {email address:{name:"Dave Leicester", address:"name.name@name.co.uk"}}
end tell
open myMsg
end tell
end open
end open
end open
on open theDroppedItems -- drop here parent folder
set parentFolder to item 1 of theDroppedItems -- result: alias
tell application "Finder"
tell parentFolder to set childFolder to item 1 of its folders -- result: Finder reference
tell childFolder to set theAi to (first file whose name extension is "ai") as alias -- result: alias
end tell -- finds the Illustrator file within the sub child Artwork folder
-- the rest stuff
end open -- 1 end open instead of 3 end open
Thanks for this - I keep getting this error though?
Can’t get every «class cfol» of alias “Dave’s Mac:Users:uk:Desktop:test file 76477 - Tube Moisture Deep Conditioning Treatment - Mibelle:”. (-1728)
The filename “test file 76477 - Tube Moisture Deep Conditioning Treatment - Mibelle” is the Parent folder.
Here’s the script with your block replacing my on open etc.
Any clues on what I’m doing wrong?
on open theDroppedItems – drop here parent folder
set parentFolder to item 1 of theDroppedItems -- result: alias
tell application "Finder"
tell parentFolder to set childFolder to item 1 of its folders -- result: Finder reference
tell childFolder to set theAi to (first file whose name extension is "ai") as alias -- result: alias
end tell -- finds the Illustrator file within the sub child Artwork folder
-- the rest stuff
tell application "Adobe Illustrator"
activate
open theAi -- opens the Illustrator file from the sub child Artwork folder
tell document 1
do script "APPROVED RELEASE FILE" from "Dave's" -- runs the specific Illustrator Action (preps for release, outlines, changes approval layer, etc)
end tell
end tell
tell application "Finder"
repeat
try
alias "Dave's Mac:Users:uk:Desktop:PDF's:Not Distilled:"
tell application "Finder"
set a to "Dave's Mac:Users:uk:Desktop:PDF's:Not Distilled:" as alias
delay 0.1
duplicate files of entire contents of a to theDroppedItems with replacing
end tell
tell application "MakeZipOnly"
activate
open theDroppedItems
end tell
exit repeat
end try
delay 0.1
delete files of entire contents of a
end repeat
tell application "Finder"
set a to "Dave's Mac:Users:uk:Desktop:PDF's:Not Distilled:" as alias
set b to "Dave's Mac:Volumes:TamworthMacRAID:TEMPORARY FILE TRANSFERS:RELEASES:PDF's:" as alias
move files of entire contents of a to b with replacing
end tell
delay 0.1
delete files of entire contents of a
end tell
tell application "Finder"
set NameOfFile to (name of (info for theDroppedItems))
set NameOfFile to text 1 thru ((offset of "." in NameOfFile) - 1) of NameOfFile
set myFile to theDroppedItems as alias
end tell
tell application "Microsoft Outlook"
set mySubject to NameOfFile & " APPROVED FILE RELEASE" as text
set myContent to "<p style=font-family:Calibri>Hi</p><p style=font-family:Calibri>Attached is the Approved Release File for " & NameOfFile & "<p style=font-family:Calibri>Thanks</p>"
set myAttachment to theDroppedItems
set myMsg to make new outgoing message with properties {subject:mySubject, content:myContent}
tell myMsg
make new attachment with properties {file:myFile}
make new recipient with properties {email address:{name:"name", address:"name@name.co.uk"}}
end tell
open myMsg
end tell
end open
tell application "Finder"
repeat
try
alias "Dave's Mac:Users:g-uk-tam1-retail-2:Desktop:PDF's:Not Distilled:"
tell application "Finder"
set a to "Dave's Mac:Users:g-uk-tam1-retail-2:Desktop:PDF's:Not Distilled:" as alias
delay 0.1
duplicate files of entire contents of a to theDroppedItems with replacing
end tell
tell application "MakeZipOnly"
activate
open theDroppedItems
end tell
exit repeat
end try
delay 0.1
delete files of entire contents of a
end repeat
tell application "Finder"
set a to "Dave's Mac:Users:g-uk-tam1-retail-2:Desktop:PDF's:Not Distilled:" as alias
set b to "Dave's Mac:Volumes:TamworthMacRAID:TEMPORARY FILE TRANSFERS:RELEASES:PDF's:" as alias
move files of entire contents of a to b with replacing
end tell
delay 0.1
delete files of entire contents of a
end tell
tell application "Finder"
set NameOfFile to (name of (info for theDroppedItems))
set NameOfFile to text 1 thru ((offset of "." in NameOfFile) - 1) of NameOfFile
set myFile to theDroppedItems as alias
end tell
tell application "Microsoft Outlook"
set mySubject to NameOfFile & " APPROVED FILE RELEASE" as text
set myContent to "<p style=font-family:Calibri>Hi</p><p style=font-family:Calibri>Attached is the Approved Release File for " & NameOfFile & "<p style=font-family:Calibri>Thanks</p>"
set myAttachment to theDroppedItems
set myMsg to make new outgoing message with properties {subject:mySubject, content:myContent}
tell myMsg
make new attachment with properties {file:myFile}
make new recipient with properties {email address:{name:"name", address:"name@name.co.uk"}}
end tell
open myMsg
end tell
end open
It was my mistake. 1 more coercion is needed:
on open theDroppedItems -- drop here parent folder
set parentFolder to item 1 of theDroppedItems -- result: alias
tell application "Finder"
set parentFolder to folder (parentFolder as text) -- result: Finder reference, ADDED
tell parentFolder to set childFolder to folder 1 -- result: Finder reference, EDITED
tell childFolder to set theAi to (first file whose name extension is "ai") as alias -- result: alias
end tell -- finds the Illustrator file within the sub child Artwork folder
-- the rest stuff
end open -- 1 end open instead of 3 end open