Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tbone82

macrumors newbie
Original poster
Aug 5, 2006
3
0
I have never really programmed anything before other than a TI-83 calculator in high school years ago... but I got my Mac in January, and I was curious to try out AppleScripts, since the OS X overview implied it was so easy.
All I want to do is tell it to print a bunch of pdf files without printing the first page of any of them (pages 2-?). I decided to try it out by just opening one of the files. Preview wasn't in the list of programs to use AppleScripts with, so I decided to use Safari. I made the following script:

tell application "Safari"
open file "Macintosh HD/Excerpts/Wagner/Lohengrin_prelude.pdf"
end tell

This was following what little basic information I could find in AppleScript help and online at <http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/AppleScript.fd.html>

However, when I try to run this script, Safari tells me that there is no file at that address!

Did I do something wrong?

Thanks

Tommy
 

HiRez

macrumors 603
Jan 6, 2004
6,250
2,576
Western US
Well I'll ask the obvious first...are you absolutely sure the file and path are spelled/typed correctly? For example, you really should not have a folder named "Excerpts" directly under your root in OS X. If you do, something is wrong. It should look something more like:

/Volumes/Macintosh HD/Users/<your user name here>/Documents/Excerpts/Wagner/Lohengrin_prelude.pdf

or

/Users/<your user name here>/Documents/Excerpts/Wagner/Lohengrin_prelude.pdf

(You may not need the first two components if you only have one hard drive). One way to get an accurate full path is to open Terminal, drag the file into it, and select and copy the path that appears.

EDIT: I think I see what is going on here: the article you linked dates from 1999, so it was probably written for OS 9 or maybe a very, very early version of OS X. You need to find a more modern one (sorry, I don't do much AppleScript so I can't help you there, but Google it for starters and always check the dates on online articles when you're looking to learn something).
 

tbone82

macrumors newbie
Original poster
Aug 5, 2006
3
0
Actually, I dragged the "Excerpts" folder directly in Macintosh HD myself to uncomplicate things when typing it in the script...it was in my Desktop before.

Thanks for the reply
 

HexMonkey

Administrator emeritus
Feb 5, 2004
2,240
504
New Zealand
Changing the slashes to colons should fix it.

ie
Code:
tell application "Safari"
	open file "Macintosh HD:Excerpts:Wagner:Lohengrin_prelude.pdf"
end tell
 

tbone82

macrumors newbie
Original poster
Aug 5, 2006
3
0
HexMonkey said:
Changing the slashes to colons should fix it.

ie
Code:
tell application "Safari"
	open file "Macintosh HD:Excerpts:Wagner:Lohengrin_prelude.pdf"
end tell

Thanks HexMonkey...that worked. Now...the question is, how do I tell it to print a file omitting page 1? Is there a way to do this without specifying the ending page?

Thanks all
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
You haven't mentioned which Mac OS X version you have, but this Automator workflow runs on Mac OS X 10.4 and up.

Basically it does everything you want, printing PDFs starting at page 2. And it doesn't use AppleScript at all.

The folder to get PDFs from is "PDF To Print" and the temporary storage area for printing is set to the Desktop, but you can easily change it.

This will leave page 1 from the PDFs on the Desktop/in the temp folder, but hey you can easily find and manually trash them after processing. Or make an AppleScript to do it.
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
Here's a better version. This one extracts the pages as separate PDFs and not images, and it should keep the pagination straight.
 

Attachments

  • PrintPDF2.workflow.zip
    4.6 KB · Views: 91

SC68Cal

macrumors 68000
Feb 23, 2006
1,642
0
Sayer said:
And it doesn't use AppleScript at all.

Not to be a nit picker, but I believe Automator is a GUI and User Friendly version of Applescript, that allows people with absolutely no skills with scripting languages to do scriptable tasks.

The penalty is that Automator workflows are bloated compared to their applescript equivalents.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.