Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 5, 2006, 02:44 PM   #1
tbone82
macrumors newbie
 
Join Date: Aug 2006
AppleScript...am I just dumb?

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
tbone82 is offline   0 Reply With Quote
Old Aug 5, 2006, 02:55 PM   #2
HiRez
macrumors 601
 
HiRez's Avatar
 
Join Date: Jan 2004
Location: 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).
__________________
Go outside, the graphics are amazing!
HiRez is offline   0 Reply With Quote
Old Aug 5, 2006, 03:03 PM   #3
tbone82
Thread Starter
macrumors newbie
 
Join Date: Aug 2006
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
tbone82 is offline   0 Reply With Quote
Old Aug 5, 2006, 07:17 PM   #4
HexMonkey
Administrator
 
HexMonkey's Avatar
 
Join Date: Feb 2004
Location: 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
HexMonkey is offline   0 Reply With Quote
Old Aug 6, 2006, 08:13 AM   #5
tbone82
Thread Starter
macrumors newbie
 
Join Date: Aug 2006
Quote:
Originally Posted by HexMonkey
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
tbone82 is offline   0 Reply With Quote
Old Aug 6, 2006, 10:56 AM   #6
Sayer
macrumors 6502a
 
Sayer's Avatar
 
Join Date: Jan 2002
Location: 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.
__________________
Obama is a true statesman whose experience as a state senator, half-term US Senator & guest lecturer in a Constitutional Law class has fully prepared him to take control of our nuclear arsenal.-Me

Last edited by Sayer; Nov 18, 2008 at 08:54 AM.
Sayer is offline   0 Reply With Quote
Old Aug 6, 2006, 03:11 PM   #7
Sayer
macrumors 6502a
 
Sayer's Avatar
 
Join Date: Jan 2002
Location: 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.
Attached Files
File Type: zip PrintPDF2.workflow.zip (4.6 KB, 16 views)
__________________
Obama is a true statesman whose experience as a state senator, half-term US Senator & guest lecturer in a Constitutional Law class has fully prepared him to take control of our nuclear arsenal.-Me
Sayer is offline   0 Reply With Quote
Old Aug 6, 2006, 04:30 PM   #8
SC68Cal
macrumors 68000
 
Join Date: Feb 2006
Quote:
Originally Posted by Sayer
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.
SC68Cal is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
AppleScript: How do I save multiple Excel sheets to one pdf using Applescript sbtaylor1 Mac Programming 0 Oct 28, 2013 11:38 PM
AppleScript: How do I save multiple Excel sheets to one pdf using Applescript sbtaylor1 Mac Applications and Mac App Store 0 Oct 28, 2013 11:32 PM
HELP I did something really dumb macattackwak Mac Basics and Help 8 Aug 20, 2013 10:27 AM
Think I've been really dumb brobson Mac Basics and Help 4 Dec 12, 2012 03:26 PM
Who is this dumb? MorphingDragon Community Discussion 10 Jul 19, 2012 02:55 AM

Forum Jump

All times are GMT -5. The time now is 06:14 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC