LoginSignup
0
1

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

Last updated at Posted at 2020-11-04

#複数バージョンの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とパス名は記憶に頼ってるので不正確です…………
		set BridgeA to ":Adobe Bridge Opener Preferences.xml"
		set BridgeB to ":AdobeBridgeOpenerPreferences.xml"
		if bridgeIdentify is "com.adobe.bridge12" then set bPath to "Bridge 2022" & BridgeA
		if bridgeIdentify is "com.adobe.bridge11" then set bPath to "Bridge 2021" & BridgeA
		if bridgeIdentify is "com.adobe.bridge13" then set bPath to "Bridge 2023" & BridgeB
		if bridgeIdentify is "com.adobe.bridge9" then set bPath to "Bridge CC 2019" & BridgeA
	end if
end tell

tell application "Finder"
	activate
	set fileTarget to (home as text) & "Library:Application Support:Adobe:" & (bPath as text)
	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

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1