PDFの必要な情報を取得する [AppleScript辞書はつくれるか?]
いくつもあるPDFの、とある情報が素早く見たかったのでスクリプトを作ってみました。
アプリケーション形式と変換形式の2つがほしかったのです。
そこから必要な部分を抜き出す処理をしてみる。
(* 選択されたファイルを使用する場合 *) tell application "Finder" set selectionItem to selection end tell repeat with logationUrl in selectionItem set logationUrl to logationUrl as text set ans to my thekMDItemCreator(logationUrl) display dialog ans end repeat
(* ドロプレット部分 *) on open dropItem repeat with logationUrl in dropItem set ans to my thekMDItemCreator(logationUrl) display dialog ans end repeat end open
(* 情報取得部分 *) on thekMDItemCreator(logationUrl) --| 適切なPOSIXパステキストを取得 | set logationUrl to logationUrl as text if logationUrl contains ":" then set logationUrl to POSIX path of logationUrl --| 情報の取得と処理 | set aName to "File:" & return & " " & (text 39 thru -2 of (do shell script ("mdls \"" & logationUrl & "\" | grep 'kMDItemFSName'"))) try set ans1 to "使用アプリケーション:" & return & " " & (text 39 thru -2 of (do shell script ("mdls \"" & logationUrl & "\" | grep 'kMDItemCreator'"))) set ans2 to "PDF変換:" & return & " " & (text 6 thru -2 of (do shell script ("mdls \"" & logationUrl & "\" | grep -A1 'kMDItemEncodingApplications' | tail -n 1"))) set ans to aName & return & ans1 & return & ans2 on error --| 未対応のファイルだった場合の処理 | set ans to aName & return & return & " は未対応のファイルです" end try return ans end thekMDItemCreator
|
(これそのものが必要になる人はまあいないでしょうが…)
コメント 0