Help to Get HAZEL to run script then move both files

I really tried! Over & Over again!
I down loaded the trial version. If I can get this to work for my company they will buy several versions.
But I can not figure out how to get HAZEL to run the script! I think this is probably easy but I can not figure it out!!!! I did read Hazel help on working with scripting but still not sure what to do? I am completely new to scripting.
I would like HAZEL to run the script below on one file at a time,
THEN I need HAZEL to move both finished .ai & new converted .pdf files (When script is done) to certain folders based on the first 6 characters of the name.
Example any files starting with "ILCJ54.ai" & "ILCJ54.pdf" would be moved to folder "C520-13 CJ54" Plus any files
"ILDG93.ai" & "ILDG93.pdf" would be moved to folder "CD4.1-14 DG93" & so on.
I would need HAZEL to work from one script so that when I add or subtract from the script their will only be one script to edit. So I think that the "For external scripts" option is what would do this.
Please, does anyone know how to get this to work? I would be so thankful!!
Computer info:
Model: imac
AppleScript: 2.3
Browser: Safari 534.55.3
Operating System: Mac OS X (10.6)
I down loaded the trial version. If I can get this to work for my company they will buy several versions.
But I can not figure out how to get HAZEL to run the script! I think this is probably easy but I can not figure it out!!!! I did read Hazel help on working with scripting but still not sure what to do? I am completely new to scripting.
I would like HAZEL to run the script below on one file at a time,
The script below opens any .ai Illustrator file to save as a .pdf then opens the .pdf in Acrobat Pro to "Enable Commenting & Measuring..."
THEN I need HAZEL to move both finished .ai & new converted .pdf files (When script is done) to certain folders based on the first 6 characters of the name.
Example any files starting with "ILCJ54.ai" & "ILCJ54.pdf" would be moved to folder "C520-13 CJ54" Plus any files
"ILDG93.ai" & "ILDG93.pdf" would be moved to folder "CD4.1-14 DG93" & so on.
I would need HAZEL to work from one script so that when I add or subtract from the script their will only be one script to edit. So I think that the "For external scripts" option is what would do this.
- Code: Select all
-- 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
my process_documents()
end repeat
end SaveFilesAsPDF
-- Call handler
set sourceFolder to "Macintosh HD:Users:Dave:Desktop:Illustrator:"
tell application "Finder" to set fileList to every file of folder sourceFolder -- "Macintosh HD:Users:b3po:Public:AI to PDF to Enabled" as alias list
set destFolder to "Macintosh HD:Users:Dave:Desktop:PDF:"
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"
on process_documents()
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 process_documents
Please, does anyone know how to get this to work? I would be so thankful!!
Computer info:
Model: imac
AppleScript: 2.3
Browser: Safari 534.55.3
Operating System: Mac OS X (10.6)