Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

Bridgeで開くPhotoshopバージョンを一気に変更するAppleScript

複数バージョンのPhotoshopをインストールしている方へ

BridgeはOSの関連付けと関係無くアプリケーションを指定できますが、複数バージョンのPhotoshop等入れている場合はよく使うバージョンを固定しておきたい、ですよね
プレリリース版がいちいち起動してたら面倒なので…

~/Library/Application Support/Adobe/Bridge 2021/Adobe Bridge Opener Preferences.xml
からsedでPhotoshopの行を探して、アプリケーション本体のパスを書き込みます。

--Bridgeバージョン取得
tell application "System Events"
    set bridgeIdentify to null
    set alist to bundle identifier of every process
    repeat with i from 1 to count of alist
        set a to item i of alist
        if a contains "com.adobe.bridge" then
            set bridgeIdentify to a as text
        end if
    end repeat
    if bridgeIdentify is null then
        display alert "バージョンを取得したいので、Bridgeは起動しておいてください"
        error number -128
    else
        --フォルダ名判別。bundleIDとパス名は記憶に頼ってるので不正確です…………
        if bridgeIdentify is "com.adobe.bridge11" then set bPath to "Bridge 2021"
        if bridgeIdentify is "com.adobe.bridge10" then set bPath to "Bridge 2020"
        if bridgeIdentify is "com.adobe.bridge9" then set bPath to "Bridge CC 2019"
    end if
end tell

tell application "Finder"
    set fileTarget to (home as text) & "Library:Application Support:Adobe:" & (bPath as text) & ":Adobe Bridge Opener Preferences.xml"

    try --実在判定
        fileTarget as alias
    on error
        display alert "設定ファイルがありません。Bridge環境設定「ファイルタイプの関連付け」で、PNGなどの設定を適当に変更すると、自動的に環境設定ファイルが作成されますので、もう一度このスクリプトを実行してください"
        return
    end try
    set fileTarget to do shell script "echo " & fileTarget & " | sed -e 's| |\\\\ |g'"
    --xml書き替え。app_name="Photoshop"を探して、それ以降をapp_pathで書き替える
    set app_path to (choose file with prompt "Photoshop本体を選択してください")'s POSIX path
    set nameTemp to (items 1 thru -2 of characters of app_path)
    set app_path to POSIX path of (nameTemp as string)
    do shell script "sed -i -e 's|\\(app_name=\"Photoshop\"\\).*|\\1 app_path=\"" & app_path & "\">|g' " & POSIX path of fileTarget
end tell

set Bridge to application id bridgeIdentify
if Bridge is running then tell Bridge to quit
repeat while Bridge is running
    delay 0.5
end repeat
tell Bridge
    activate
    display alert "書き替えました"
end tell
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away