私は素晴らしい NEF RAW ファイルを出力するニコンのカメラを持っていますが、それほど素晴らしい JPEG ファイルは出力しません。Mac OSX 10.6.8 (Snow Leopard) に付属の Preview アプリを使用して NEF を開き、SaveAs JPEG を使用して、元の NEF とほぼ見分けがつかないサイズの約 1/6 のファイルを作成できます。
[編集] 以下は、コメントといくつかのエラー テストを含む、希望どおりに機能する最終的なスクリプトです。
(*
AppleScript to convert Nikon raw NEF files into much smaller JPG files.
The JPG files will inherit the file date and time of the source NEF files.
Note that any JPG files in the target folder that have the same name
as a NEF file in that folder, will be overwritten.
*)
-- User selects target folder with NEF files to convert and save there.
set theImageFolder to choose folder with prompt "
Select a folder containing fileⁿ.NEF images to
convert into JPEG images and SaveAs: fileⁿ.JPG"
set theOutputFolder to theImageFolder
-- Finder locates NEF files, ignoring other file types in the target folder.
tell application "Finder"
set theImages to every file of theImageFolder whose name extension is "NEF"
end tell
-- Image Events app processes the images.
tell application "Image Events"
launch
repeat with a from 1 to length of theImages
-- Get file name as text string.
set theImage to file ((item a of theImages) as string)
-- Get date/time of source NEF file.
tell application "Finder" to set fileTimestamp to creation date of theImage
set theImageReference to open theImage
tell theImageReference
set theImageName to name
-- Detect the .NEF extension to replace with .JPG on output.
set savedDelimiters to AppleScript's text item delimiters
-- Split filename string into list, using "." as a delimiter.
set AppleScript's text item delimiters to {"."}
set delimitedList to every text item of theImageName
-- Remove the .NEF extension from the list, if it was there.
ignoring case
--Process only NEF files.
if last item of delimitedList is "NEF" then
set filenameList to items 1 thru -2 of delimitedList
set theImageName to filenameList as string
end if
end ignoring
-- Restore delimiters to default in case it had previously been changed.
set AppleScript's text item delimiters to savedDelimiters
-- Construct full path of file to save, with JPG as output file extension.
set saveImageName to ((theOutputFolder as string) & theImageName & ".JPG")
-- Check if a file with the output JPG file name is already present in the target folder.
tell application "Finder"
if exists file saveImageName then
-- Abort script if user doesn't want to overwrite this file and continue.
beep
if button returned of (display dialog " An identical JPG file is already at:
" & saveImageName & "
Would you like to:" buttons {"Replace it and continue", "Abort"} default button "Abort") is "Abort" then exit repeat
end if
end tell
-- SaveAs the file in JPEG format, leaving the source NEF file unmodified.
set saveImageName to save in saveImageName as JPEG
--Match the output JPG file date/time to that of the NEF source file.
tell application "Finder" to set modification date of saveImageName to fileTimestamp
end tell
end repeat
end tell
tell application "Finder"
display alert "Done. Duplicated selected NEF files in
" & theOutputFolder & "
as JPGs with dates/times matching NEFs."
end tell
以下は、何百もの NEF ファイルに対して Preview アプリを使って手動でこれを行うのにかかる時間を節約するために、AppleScript を作成する最初の試みでした。それは機能しますが、このウェブサイトの親切な人々は私がそれを大幅に改善するのを助けてくれました. 最初のユーザー プロンプトからわかるように、既存の JPG ファイルが置き換えられる場合にのみ、ユーザーにプロンプトを表示するようにしました。また、出力ファイル名をn .NEF.jpgではなくn .JPGにして、出力 JPG ファイルに元の NEF ファイルの作成日時を継承させたいと考えていました。私はどんな提案も歓迎したが、私はすでにここまでやってきたので、シェルスクリプトを追加するのを控え、可能であればすべて AppleScript で行うことを好みました.
set theImageFolder to choose folder with prompt "Note: This script will replace any existing files in the selected folder matching
the name of a NEF file and end in a JPG extension with a new file of that name.
For example, X.NEF will create X.JPG and replace any existing file named X.JPG
that was already in the selected folder (not in any other folders). To begin now,
Select a folder with NEF images to convert into JPEG images:"
set theOutputFolder to theImageFolder
tell application "Finder"
set theImages to every file of theImageFolder whose name extension is "NEF"
end tell
tell application "Image Events"
launch
repeat with a from 1 to length of theImages
set theImage to file ((item a of theImages) as string)
set theImageReference to open theImage
tell theImageReference
set theImageName to name
save in ((theOutputFolder as string) & theImageName & ".JPG") as JPEG
end tell
end repeat
end tell
tell application "Finder"
display alert "Done. All NEF files in the selected folder have been duplicated in JPEG format."
end tell