Have a look at post #4. and see if that gives you the “tight” conversions you want.
I do not think you will have much luck trying to get preview to work for you, as you have discovered is not scriptable and does not have a library.
EDIT here is an example.
tell application "Finder"
set target_path to ((path to desktop folder as Unicode text) as alias)
set source_item to (choose file)
set source_itemP to POSIX path of source_item
set file_name to displayed name of source_item -- get displayed name
set oldDelims to AppleScript's text item delimiters -- get normal dilm
set AppleScript's text item delimiters to {"."} --sets new dilm
set file_name to text item 1 of file_name -- get thye name of file without extension
set AppleScript's text item delimiters to oldDelims -- resets dilm
set target_pathP to POSIX path of target_path & file_name & ".pdf" as string
end tell
do shell script (" /usr/bin/pstopdf " & quoted form of source_itemP & " -o " & quoted form of target_pathP)
I read it but can’t follow what it is doing. Probably because of my lack of familiarity with scripting and total ignorance of shell scripts.
I compiled it anyway and tried it.
It asks me to find an individual file, which I did and then it doesn’t ask me for a destination. It just seems to do nothing and closes. What am I missing?
Sorry to trouble you.
btw If I could automate this, I have found a manual way to do the job:
Open dialog in Preview
Navigate to folder full of eps files
Select all in folder
All files open and are converted to pdfs automatically
Close all open windows [cmd-opt-W]
save (twice) for each dialog that comes up [waiting for each dialog to appear - being OSX it doesn’t let me key ahead]
…till no windows are open
It drops all pdf files back into the originating folder
Next step would working out how to get it to step through a series of subfolders doing the same thing.
Actually It only took 5mins to write the automator action.
I will post it on one of my pages. As I do not think I can post here. But will walk you through here also.
Ok here is how to build the automator action.
In Automator.
From the FINDER actions.
choose the following action and set it as below -Ask for Finder items-
type : Folders
Start at : where ever you want
Prompt : Choose a Folder:
allow multiple Selections (un ticked)
From the FINDER actions.
choose the following action and set it as below -Get Folder Contents-
Repeat for each Subfolder found(ticked)
–
from the AUTOMATOR actions.
choose the following action and Run Applescript Replace the script in the applescript window with this code.
on run {input, parameters}
tell application "Finder"
repeat with i from 1 to number of items of input
set source_item to item i of input
set source_itemP to POSIX path of source_item
do shell script (" /usr/bin/pstopdf " & quoted form of source_itemP)
end repeat
end tell
end run
*** EDIT ****
You are correct in regards to
do shell script (" /usr/bin/pstopdf " & quoted form of source_itemP & " -o " & quoted form of target_pathP)
being the conversion line.
And Actually I just change the above script since you want the files to be created in the original folder.
The last part of the line which name the pdf file and path is not needed.
This is what its actually doing.
do shell script " /usr/bin/pstopdf ‘/Users/username/Desktop/Photo-5.eps’ "
/usr/bin/pstopdf is shell command that does the conversion. ‘/Users/username/Desktop/Photo-5.eps’ is the unix path to the source file .
the pdf if is created in the same folder as the original if no destination of name is given.
I don’t know if you can fix Apple’s automator actions. The one for Preview’s file conversions should ideally just be extended to do the ps to pdf conversion, then it would be an all in one for graphic designers.
It stopped 2/3rds way through the 8th folder of 246. Is it possible that my actions in OSX can interrupt the Automator workflow?
I would like to get it to beep or read an announcement at the end of the conversion
The closest I have got to that is “Ask for Confirmation” throwing up “The conversion is complete, would you like to choose another folder” - Cancel/OK
Finder doesn’t read out the prompt it just tells me Automator wants my attention.
I would like the workflow to loop at this point when I click OK and send me back to step one “Ask for Finder Item”
I tried putting a copy of the workflow at this point, because I can’t see how to loop, but it rejects it as not an action/workflow. Is that because I saved it as an application?
I can’t set the path to save PDF files to a folder on my desktop
I set this do shell script " /usr/bin/pstopdf ‘/Users/myuser/Desktop/PDF’ "
but I get an error
/usr/bin/pstopdf failed on file /Users/myuser/PDF with error code -30998 (352956576)
I saw this excellent post and I couldn’t resist having meddled a bit with some systems command lately.
My version uses the the index for the command line utilities right from my hd.
I prefer this one because I generally like to see all of them. I also prefer the browser because of the hyperlinks in the reference section. However this won’t get the highlighted colors one could get with an ansi terminal.
I saved this as an applet and an alias now resides among my predefined searches.
If you don’t have the Developer tools or reference documentation installed this
line should perform equally well as long as speed is not concerned.
on run
set theCommand to ""
tell application "System Events"
set target_app to item 1 of (get name of processes whose frontmost is true)
end tell
tell application target_app
repeat while theCommand is ""
display dialog "View man page for this command:" default answer theCommand
set theCommand to text returned of result
end repeat
end tell
tell application "Safari" to open "Macintosh HD:Developer:Mac OS X Reference Library:documentation:Darwin:Reference:ManPages:index.html"
-- tell application "Safari" to open location "http://developer.apple.com/Mac/library/documentation/Darwin/Reference/ManPages/index.html"
tell application "Safari" to activate
delay 2
tell application "System Events"
key down command
keystroke "f"
key up command
keystroke theCommand & "("
end tell
end run
I’m using this, it takes the argument (syntax man something) from the address field in Safari and is triggered by a shortcut (via QuicKeys).
It opens the appropriate page on manpagez.com
The advantage of reading the man page online is that all cross-references are working
activate application "Safari"
tell application "System Events"
tell process "Safari"
set searchString to value of text field 1 of splitter group 1 of group 2 of tool bar 1 of window 1
end tell
end tell
set {TID, text item delimiters} to {text item delimiters, space}
try
set {cmd, arg} to {text item 1, text item 2} of searchString
set text item delimiters to TID
on error
set text item delimiters to TID
return
end try
if cmd does not start with "man" then return
set foundURL to createManPageURL(arg)
if foundURL is missing value then return
try
tell application "Safari"
if text of document 1 is "" then
set URL of document 1 to foundURL
else
tell window 1 to set current tab to (make new tab with properties {URL:foundURL})
end if
end tell
on error
return
end try
on createManPageURL(topic)
set section to word 2 of (do shell script "man " & topic)
return "http://www.manpagez.com/man/" & section & "/" & topic & "/"
end createManPageURL
Thanks alot for sharing your code both of you.
The only thing I regret with reading in html is that I can’t get the keywords in color as I did in terminal. I’ll post the method for doing that when I have dissected the old PowerBook.
As for now I think I’ll lend some code of stefan and rework my solution so that I use the Address Bar of Safari with
Stefans way, but My own way as a backup when I miss spell the command.
I need a third way as well and that is when the Manual Page are coming from a Macport or other installation.
I let all My custom installations of Darwin binaries reside in /usr/local/opt by the way, and anything “that can be used” for a manual file in the /usr/local/man/man* directories. I’ll implement a manOnDisk command for those.
But not today. But I must say I’m playing with the thought of making a “Webpage Helper” and use it by url and get all output into a Safari Window cross references or not.
I must tell you about visor which is a free download from binaryages.com which lets you have a terminal window in the upper left corner of your screen just by hitting ctrl ctrl ! Its here: http://www.binaryage.com/#visor
I have been using Visor for around a year now and absolutely love it! I especially like switching between tabs using {shift, command} right and left arrow.