I am working on a Script that will upload art to the various printers I use and I am having a number of issues with this section.
-
In the script below both printer “ABC” and “GHI” work correctly but “DEF Inc.” does not. I know it is because I am changing the title to DEFInc but I think I should be able to do this . Any suggestions? Is the result returned from the button push a string?
-
As is, this script only takes one folder that has been dropped. I know that by removing the “{}” from "{input_folder} allows me to drop multiple files. When I do this here though I get an error later in the script and I think I know why. I am having difficulty with telling the Finder where the new folder is to make a list of only Illustrator files. As is, I believe it is trying to make an Illustrator-only list from the multiple dropped files rather than the new folder. (Sorry that was so wordy.) How do I point it to my new folder?
-
Also, I cannot figure out how to connect to another computer on the same network. I know I need to use “mount volume” but it is not working for me yet so I didn’t even include it in the script below. Ideally, I’d like to connect to another computer at the beginning of the script and then create the new folder on that computer.
Any suggestions/comments/tips welcome. Thanks for your time.
on open {input_folder}
display dialog "Which printer would you like to upload this job to?" buttons {"ABC", "DEF Inc.", "GHI"}
set pushButton to button returned of result
if pushButton is "DEF Inc." then
set printerName to "DEFInc"
else
set printerName to pushButton
end if
set newFolderLocation to alias "Macintosh HD:Users:jon:Desktop:TEST:"
-- This is the location on the DesignerStation for each of their jobs.
set designerName to "Jon"
-- This is the designer's name. It is important for the WorkStation end script.
get current date
copy the result to today
copy today as string to dateString
if word 2 of dateString is "January" then set monthName to "01"
if word 2 of dateString is "February" then set monthName to "02"
if word 2 of dateString is "March" then set monthName to "03"
if word 2 of dateString is "April" then set monthName to "04"
if word 2 of dateString is "May" then set monthName to "05"
if word 2 of dateString is "June" then set monthName to "06"
if word 2 of dateString is "July" then set monthName to "07"
if word 2 of dateString is "August" then set monthName to "08"
if word 2 of dateString is "September" then set monthName to "09"
if word 2 of dateString is "October" then set monthName to "10"
if word 2 of dateString is "November" then set monthName to "11"
if word 2 of dateString is "December" then set monthName to "12"
if word 3 of dateString is "1" then set dayName to "01"
if word 3 of dateString is "2" then set dayName to "02"
if word 3 of dateString is "3" then set dayName to "03"
if word 3 of dateString is "4" then set dayName to "04"
if word 3 of dateString is "5" then set dayName to "05"
if word 3 of dateString is "6" then set dayName to "06"
if word 3 of dateString is "7" then set dayName to "07"
if word 3 of dateString is "8" then set dayName to "08"
if word 3 of dateString is "9" then
set dayName to "09"
else
set dayName to word 3 of dateString
end if
set shortDate to monthName & dayName
set newFolderName to shortDate & "_" & designerName & "_" & printerName
tell application "Finder" -- everything passed to the Finder here creates the new folder
try
make new folder with properties {name:newFolderName} at newFolderLocation
on error
set x to 2
set newFolderName to shortDate & "_" & designerName & "_" & printerName & x
try
make new folder with properties {name:newFolderName} at newFolderLocation
on error
set folderOK to false
repeat while folderOK is false
set x to x + 1
set newFolderName to shortDate & "_" & designerName & "_" & printerName & x
try
make new folder with properties {name:newFolderName} at newFolderLocation
set folderPath to newFolderLocation as string
if folder (folderPath & newFolderName) exists then set folderOK to true
end try
end repeat
end try
end try
set folderPath to newFolderLocation as string
move contents of input_folder to (folderPath & newFolderName)
try
set input_files to (every file of entire contents of input_folder whose kind is "Adobe Illustrator Document") as alias list
on error -- happens if there is only one
set input_files to (every item of entire contents of input_folder whose kind is "Adobe Illustrator Document") as alias as list
end try
end tell
tell application "Adobe Illustrator"
activate
set printToAcrobat to {class:print options, printer name:"Adobe PDF 7.0"}
repeat with currentFile in input_files
open currentFile
print current document options printToAcrobat
close current document saving no
end repeat
end tell
end open
Model: Quad 2.5GHz G5 & Dual 2.0Ghz G5
AppleScript: latest
Browser: Safari 2.0.3 (417.9.3)
Operating System: Mac OS X (10.4)