おもろい、めずらしいアップルスクリプト発表会 6

このエントリーをはてなブックマークに追加
241名称未設定
iPhotoからRAWファイル(.nel)をファインダに表示させる。

iPhotoの外部アプリで編集機能は、iPhotoが現像したjpegファイルの方を開いてしまうので,RAWで管理している意味があまり無い。
"Show Image FIle"等,オリジナルファイルをファインダで表示させるスクリプトは、RAWを表示させようとすると、やはりiPhotoが現像したjpegファイルの方を表示させてしまう。
結局チラシの裏にファイル名をメモしながらオリジナルを探すというアナログ回帰な毎日・・・

という訳でShow Image File を改造して、RAWファイル専用機にしてみました。

RAW+JPEG のように同名異拡張子で取り込まれたり、iPhoto内で複製、または重複取り込みで勝手に枝番が付加された場合でもオリジナルのRAWファイルにたどりつきます。

OSX 10.3.9  iPhoto 5.0.4で動作確認

↓  ↓
242名称未設定:2005/10/21(金) 17:40:55 ID:YrOVRVel
"Show Raw File" 01
tell application "iPhoto"
activate
try
copy (my selected_images()) to these_images
if these_images is false or (the count of these_images) is not 1 then error "一個づつしか調べきらんと"
set this_image to item 1 of these_images
set textName to (image filename of this_image) as text
set textName to my replaceW(textName, ".jpg", ".nef")
set textPath to (image path of this_image) as text
set textDate to (date of this_image) as text
set oldDel to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set textDate to text item 1 of textDate
set textDate to my replaceW(textDate, "-", "/")
set AppleScript's text item delimiters to "/"
set libraryName to text item ((count text item of textPath) - 4) of textPath
set AppleScript's text item delimiters to libraryName
set textPath to text item 1 of textPath
set AppleScript's text item delimiters to oldDel
set textPath to textPath & libraryName & "/" & textDate & "/Originals/" & textName
243名称未設定:2005/10/21(金) 17:41:40 ID:YrOVRVel
--"Show Raw File"02
try
set this_imagefile to ((textPath) as POSIX file) as alias
on error
try
set changePath to text item ((count item of textPath) - 5) of textPath & text item ((count item of textPath) - 4) of textPath & ".nef"
set textPath to my replaceW(textPath, changePath, ".nef")
set this_imagefile to ((textPath) as POSIX file) as alias
on error
display dialog "RAWファイルじゃなかろごたぁ"
end try
end try

on error error_message number error_number
if the error_number is not -128 then
display dialog error_message buttons {"Cancel"} default button 1
end if
end try
end tell
244名称未設定:2005/10/21(金) 17:42:26 ID:YrOVRVel
--"Show Raw File"03
tell application "Finder"
activate
set visible of (every process whose visible is true and frontmost is false) to false
reveal this_imagefile
end tell

on selected_images()
tell application "iPhoto"
try
set these_items to the selection
if the class of item 1 of these_items is album then error
return these_items
on error
return false
end try
end tell
end selected_images

on replaceW(src, tg, rp)
set oldDel to AppleScript's text item delimiters
set AppleScript's text item delimiters to tg
set myList to text items of src
set AppleScript's text item delimiters to rp
set myText to myList as string
set AppleScript's text item delimiters to oldDel
return myText
end replaceW
245名称未設定:2005/10/21(金) 17:44:01 ID:YrOVRVel
うぅ・・改行が多いと怒られた(T_T)
素人ですみません