Automator PDF結合時にエラー127がでる

PDF結合時にエラー127がでます。ここ数年は何も問題ありませんでした

* タイトルを変更しました。 Apple Inc.

MacBook Air (2020 or later)

投稿日 2022/04/07 02:23

返信
返信: 4

2022/04/20 21:45 superr25 への返信

情報ありがとうございます。ご紹介のページには「AppleScriptObjC は使えないようでした」とありますが、大丈夫のようですよ。こんな感じで作ってみました。



ショートカットを実行するとダイアログが二回表示されます。最初のダイアログで PDF ファイルを複数選択し、二つ目のダイアログで結合後のファイルの名前と場所を指定。


use AppleScript version "2.8"
use scripting additions
use framework "PDFKit"

property OSX : current application
property nil : missing value

on run
    set uti to "com.adobe.pdf"
    set msg to "PDF ファイルを選択してください。"

    set args to choose file of type uti with prompt msg with multiple selections allowed

    set pdf to OSX's PDFDocument's alloc()'s init()
    set idx to 0

    repeat with f in args
        set furl to (OSX's NSURL's fileURLWithPath:(f's POSIX path))
        set doc to (OSX's PDFDocument's alloc()'s initWithURL:furl)
        repeat with i from 1 to doc's pageCount()
            (pdf's insertPage:(doc's pageAtIndex:(i - 1)) atIndex:idx)
            set idx to idx + 1
        end repeat
    end repeat

    set fpath to choose file name default name "out.pdf" default location (path to desktop)

    if pdf's writeToFile:(fpath's POSIX path) then
        return fpath as text
    else
        error "failed to write to file \"" & fpath & "\""
    end if
end run


動作確認: Parallels Desktop 17 上の Monterey 12.3


このスレッドはシステム、またはAppleコミュニティチームによってロックされました。 問題解決の参考になる情報であれば、どの投稿にでも投票いただけます。またコミュニティで他の回答を検索することもできます。

Automator PDF結合時にエラー127がでる

Apple サポートコミュニティへようこそ
Apple ユーザ同士でお使いの製品について助け合うフォーラムです。Apple Account を使ってご参加ください。