i am trying to write a script that will print my pdfs from my tiBook when i get back to my desk. for me, printing with batch commands often loses docs or the last page of docs as they are shoved through the printer all at once. so i want to print them one at a time in order. i can get the first one going, but how can i get the second one, etc?
property myFolder : (alias "My HD:Users:userName:Desktop:my to print folder:") -- the watched folder
set myfiles to list folder myFolder without invisibles -- store list of items in folder without invisible files
set myfirstfile to ((myFolder as string) & item 1 of myfiles) as string -- get the name of the first file
set myFolder to myFolder as string -- ensure that myFolder holds path to the folder as string
tell application "Acrobat 5.0"
activate -- bring up acrobat
delay 5
open alias myfirstfile -- acrobat opens that new file
delay 3
tell application "System Events" -- to click the batch command
click menu item " Print Open File" of menu 1 of menu item "Batch Processing" of menu "File" of menu bar 1 of process "Acrobat 5.0"
delay 10
end tell
tell application "Acrobat 5.0"
activate -- bring up acrobat
tell application "System Events"
tell process "Acrobat 5.0"
keystroke "w" with command down -- closes the unwanted new document
end tell
end tell
end tell
end tell
repeat with i from 2 to count of myfiles
end repeat
Um, what? I don’t quite understand what you are doing. First, why are you using GUI scripting when Acrobat 5 is scriptable? Next, what you want to repeat has to go inside of the repeat block. Why are you designating a file as first and second? If you simply want to print out all PDFs in a folder, try this script (note you can modify the print options by uncommenting the line starting with “print pages” and setting the parameters to your needs):
If I’m on my laptop but not connected to my printer, I open Print Center, stop jobs for my current printer, then run this script. When I am connected to my printer again, I open Print Center and start jobs.
i got it repeating for each file in the folder; i also added a bit at the end to check for or create a ‘just printed’ folder on the desktop and then move the printed files into it.
property myFolder : (alias "MyHD:Users:userName:Desktop:my to print folder:") -- the watched folder
set myfiles to list folder myFolder without invisibles -- store list of items in folder without invisible files
repeat with myfile in myfiles
set mycurrentfile to ((myFolder as string) & (myfile as string)) as string -- get the name of the current file
batchprint(mycurrentfile)
end repeat
on batchprint(mycurrentfile)
tell application "Acrobat 5.0"
activate -- bring up acrobat
delay 5
open alias mycurrentfile -- acrobat opens that new file
delay 3
tell application "System Events" -- to click the batch command
click menu item " Print Open File" of menu 1 of menu item "Batch Processing" of menu "File" of menu bar 1 of process "Acrobat 5.0"
delay 10
end tell
tell application "Acrobat 5.0"
activate -- bring up acrobat
tell application "System Events"
tell process "Acrobat 5.0"
keystroke "w" with command down -- closes the unwanted new document
end tell
end tell
end tell
end tell
tell application "Finder" -- to move the printed file out
set x to (("myHD:Users:userName:Desktop:recently printed:") as text)
if alias x exists then
beep
else
make new folder at the desktop with properties {name:"recently printed"}
end if
move alias mycurrentfile to folder "recently printed"
end tell
end batchprint