私は、Adobe Acrobatを使用してPDFファイルのOCRを実行する素晴らしいAppleScriptドロップレットを持っています。私はかなり良いPythonプログラマーですが、AppleScriptを本当に理解していません。私はOCRする必要がある私のシステム上のすべてのPDFのリストを持っています。スクリプトの一番上をそれぞれドラッグする必要があるのは本当に迷惑でしょう。私はドロップレットの各スクリプトを処理する小さなPythonプログラムを持っているか、そうでなければスクリプトを修正してテキストファイルを読み込んでドロップするようにしたいと思っています。AppleScriptのドロップレットを異なるファイル名で繰り返し呼び出すにはどうすればよいですか?
私は、単一のテストでPDFファイルを開くにはosascript
を使用してみました:
tell application "OCRIt-Acrobat"
open alias "imac3:Users:vy32:FFJ.pdf"
end tell
そして、私はこの素敵なエラーました:まあ、それはあまりにも便利ではありません
31:103: execution error: OCRIt-Acrobat got an error: alias "imac3:Users:vy32:FFJ.pdf" of «script» doesn’t understand the open message. (-1708)
を。
私は何をすべきか知っていますか?ここで
は、そのすべての栄光に、OCRIt-のAcrobatです:
property mytitle : "ocrIt-Acrobat"
-- Modified from a script created by Macworld http://www.macworld.com/article/60229/2007/10/nov07geekfactor.html
-- I am called when the user open the script with a double click
on run
tell me
activate
display dialog "I am an AppleScript droplet." & return & return & "Please drop a bunch of PDF files onto my icon to batch OCR them." buttons {"OK"} default button 1 with title mytitle with icon note
end tell
end run
-- I am called when the user drops Finder items onto the script icon
-- Timeout of 36000 seconds to allow for OCRing really big documents
on open droppeditems
with timeout of 36000 seconds
try
repeat with droppeditem in droppeditems
set the item_info to info for droppeditem
tell application "Adobe Acrobat Pro"
activate
open droppeditem
end tell
tell application "System Events"
tell application process "Acrobat"
click the menu item "Recognize Text Using OCR..." of menu 1 of menu item "OCR Text Recognition" of the menu "Document" of menu bar 1
try
click radio button "All pages" of group 1 of group 2 of group 1 of window "Recognize Text"
end try
click button "OK" of window "Recognize Text"
end tell
end tell
tell application "Adobe Acrobat Pro"
save the front document with linearize
close the front document
end tell
end repeat
-- catching unexpected errors
on error errmsg number errnum
my dsperrmsg(errmsg, errnum)
end try
end timeout
end open
-- I am displaying error messages
on dsperrmsg(errmsg, errnum)
tell me
activate
display dialog "Sorry, an error occured:" & return & return & errmsg & " (" & errnum & ")" buttons {"Never mind"} default button 1 with icon stop with title mytitle
end tell
end dsperrmsg
ありがとう!
ありがとうございました。ファイルはすべて別のフォルダにありますが、すべてのファイルにシンボリックリンクを持つ単一のフォルダを作成することができます。 (これは私には以前は起こりませんでした)。 '/ real/file/names/with/slashes'の上にスクリプトを書いてもいいですか、あるいは::Crazy:AppleScript:Filenames:With:Colons'を与える必要がありますか? – vy32
AppleScriptはHFSを必要とします( ':Crazy:AppleScript:ファイル名:with:コロン') –
Ugh。これは狂った言葉です。 Pythonでファイルを開く簡単な方法があることを願っています... – vy32