I just started looking into using Applescript.
I’m working on creating a folder that when I drop 1 or 300 Illustrator files into it the script will
1) Open the .ai file in Illustrator save as .pdf with same name. (I have a script that does this see Script #1 below)
2) Then opens the .pdf file in Acrobat Pro & converts pdf to “Enable Commenting & Measuring” keeping the same name (I have a script that does this see Script #2 below)
Note: I do not know how to combined them into one script so the script does this to each file one at a time.
3) Then when 1 & 2 are complete I would like the .ai file & converted .pdf file to be moved to a different folder based on the first 6 characters of its name.
Example:
If a file is named “ILDG93-180101-14401-AA01.ai” then because it starts with “ILDG93” it will know to move both files .ai & .pdf to a folder called “CD4.1”
but then
If a file is named “ILCJ54-180101-14401-AA01.ai” then because it starts with “ILCJ54” it will know to move both files .ai & .pdf to a folder called “C520” & so on…
4) Then moves on to the next .ai file until all are complete.
One more thing I was hoping that if 10 files were dropped into the folder & it was in the middle of processing the 10 .ai files & at that time more files were dropped into the folder it would be able to just keep working on the 10 & continue to the new files until all are done.
If anyone knows how to do any of this even if not all I’m asking I would be so THANKFUL!
Script #1 SAVE AS .ai as .pdf
-- fileList is a list of aliases to Illustrator files
-- destFolder is an alias to a folder where PDF files are saved
on SaveFilesAsPDF(fileList, destFolder)
set destPath to destFolder as Unicode text
repeat with aFile in fileList
tell application "Finder" to set fileName to name of aFile
set newFilePath to destPath & fileName
tell application "Adobe Illustrator"
open aFile
save current document in file newFilePath as pdf with options {class:PDF save options, acrobat layers:false, compatibility:Acrobat 8, preserve editability:false, font subset threshold:0.0}
close current document saving no
end tell
end repeat
end SaveFilesAsPDF
-- Call handler
set sourceFolder to "Macintosh HD:Users:b3po:Public:AI to PDF to Enabled"
tell application "Finder" to set fileList to every file of folder "Macintosh HD:Users:b3po:Public:AI to PDF to Enabled" as alias list
set destFolder to "Macintosh HD:Users:b3po:Public:PDF Enabler:"
SaveFilesAsPDF(fileList, destFolder)
--tell application "Finder" to set theFiles to every document file of folder "Macintosh HD:Users:b3po:Public:AI to PDF to Enabled" whose file type ends with "ai"
Script #2 CONVERT pdf “Enable Commenting & Measuring”
property documentList : {}
on open names
set documentList to {}
tell application "Finder"
repeat with i in names
set documentList to documentList & ((i as alias) as string)
end repeat
repeat with i in documentList -- in case multiple objects dropped on applet
if i ends with ":" then -- if object is a folder process its contents too
set newList to entire contents of (i as alias)
repeat with j in newList
set documentList to documentList & (j as string)
end repeat
end if
end repeat
end tell
my process_documents(documentList)
end open
on process_documents(theList)
repeat with aDocument in theList
if (aDocument does not end with ":") then
tell application "Adobe Reader"
set myDocument to open (alias aDocument)
end tell
tell application "System Events"
try
tell process "Acrobat"
-- bring acrobat to the front
set frontmost to true
set windowName to value of static text 1 of window 1
-- select the enable commenting menu item
try
-- Acrobat Pro 9
click menu item "Enable for Commenting and Analysis in Adobe Reader..." of menu 1 of menu bar item "Comments" of menu bar 1
on error
-- Acrobat Pro X
try
-- OS X Snow Leopard
click menu item "Enable Commenting & Measuring..." of menu 1 of menu item "Reader Extended PDF" of menu 1 of menu item "Save As..." of menu 1 of menu bar item "File" of menu bar 1
on error
-- OS X Lion
click menu item "Enable Commenting & Measuring..." of menu 1 of menu item "Reader Extended PDF" of menu 1 of menu item "Save As" of menu 1 of menu bar item "File" of menu bar 1
end try
end try
-- change save as filename
-- wait until save dialog is opened
set saveDialogActive to false
repeat until saveDialogActive is true
try
set fileName to value of text field 1 of window "Save As"
set saveDialogActive to true
on error
set saveDialogActive to false
end try
end repeat
set value of text field 1 of window "Save As" to fileName
-- save file
click button "Save" of window "Save As"
if exists sheet 1 of window "Save As" then
click button "Replace" of sheet 1 of window "Save As"
end if
end tell
end try
end tell
-- stop processing until window is closed
set windowActive to true
repeat until windowActive is false
tell application "System Events"
try
tell process "Acrobat"
-- bring acrobat to the front
set frontmost to true
-- close file
click button 1 of window windowName
set windowName to value of static text 1 of window 1
end tell
on error
set windowActive to false
end try
end tell
end repeat
end if
end repeat
end process_documents
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
Model: imac
AppleScript: 2.3
Browser: Safari 534.55.3
Operating System: Mac OS X (10.6)