Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript Help

I have a script with credit to Mac Sparky which OCRs a document in PDF Pen and saves in same place
I want to modify it to save in a different predesignated folder.
Can someone help me and show how to do that.
Here is the script


-- Downloaded From: http://www.documentsnap.com
-- Last Modified: 2010-09-28
-- Includes code from MacSparky http://www.macsparky.com/blog/2009/5/24 … cript.html
-- Includes code from C-Command Software http://c-command.com/scripts/eaglefiler/ocr-with-pdfpen


on adding folder items to this_folder after receiving added_items
try
repeat with added_item in added_items
my ocr(added_item)
end repeat
on error errText
display dialog "Error: " & errText
end try
end adding folder items to


on ocr(added_item)
tell application "PDFpen"
open added_item as alias
tell document 1
ocr
repeat while performing ocr
delay 1
end repeat
delay 1
close with saving
end tell
end tell
end ocr

iMac (27-inch, Late 2012), OS X Mountain Lion (10.8.2)

Posted on Jan 31, 2013 7:46 AM

Reply
Question marked as Best reply

Posted on Jan 31, 2013 8:18 AM

You should always read the applescript dictionary. PDF Pen's close command looks like this:


closev : Close an object.

close specifier : the object to close

[saving yes/no/ask] : Specifies whether changes should be saved before closing.

[saving in file] : The file in which to save the object.



meaning that all you need to do is specify the file like so


close with saving saving in file defaultPath


the only tricky thing is whether the 'saving in' parameter is smart enough to accept a folder path or if it needs you to construct a full fuile path by adding the name of the file to the default path. play weith it and see what happens.

4 replies
Question marked as Best reply

Jan 31, 2013 8:18 AM in response to uromax

You should always read the applescript dictionary. PDF Pen's close command looks like this:


closev : Close an object.

close specifier : the object to close

[saving yes/no/ask] : Specifies whether changes should be saved before closing.

[saving in file] : The file in which to save the object.



meaning that all you need to do is specify the file like so


close with saving saving in file defaultPath


the only tricky thing is whether the 'saving in' parameter is smart enough to accept a folder path or if it needs you to construct a full fuile path by adding the name of the file to the default path. play weith it and see what happens.

Jan 31, 2013 8:19 AM in response to uromax

if PDFpen is not renaming the file in anyway, then you could something as simple as


on adding folder items tothis_folderafter receivingadded_items

try

repeat with added_item in added_items

my ocr(added_item)


tell application "Finder"


moveadded_itemto (path tohome folder)

end tell


end repeat

on error errText

display dialog "Error: " & errText

end try

end adding folder items to


which would move the file to your home folder. The other possibility is to have PDPpen save the output to the place you want it ito be.


Without more info it's difficult to get mpore specific

Feb 1, 2013 8:44 AM in response to uromax

(path to documents folder) will return /Users/user/Documents so if the file is going there that is all you need.


if there is a folder in the documents folder you want to put the file do


(((path to documents folder) as text) & "subfolder")


So this bit of Applescript moves a file called images.jpg from my home folder to a folder "Credit" in my Documents folder


set ff to (((path to documents folder) as text) & "Credit")


tell application "Finder"

move ((path to home folder) as text) & "images.jpg" to ff

end tell



but twtwtw's suggestion to use PDFpen's ability to save the file where you want it is probably the better way to go.

Applescript Help

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.