09. Image Eventsで参照用画像作成2013-04-27

wallpaperフォルダ
上図のように、画像フォルダ群を納めた親フォルダの中に_Picture indexフォルダを作成、各画像フォルダの名前の参照用画像を収納します。
わたしのように「整理できない多くの画像フォルダの参照に困ったら」お助けになるかも、そんな用途です(笑)。
スクリプトは親フォルダ(上図でのwallpaperフォルダ)を選択しながら実行してください。なお_Picture indexフォルダが既に存在するとエラー起こしますので、再実行の場合は前に削除必要です。

tell application "Finder"

set rootfolder to selection as alias
set aList to every folder of (entire contents of rootfolder)

make new folder at rootfolder with properties {name:"_Picture index"}
set indexpath to (rootfolder as text) & "_Picture index:"
end tell

repeat with i from 1 to count of aList
set tgtFolder to item i of aList
repeat with h from 1 to count of tgtFolder
set www to item h in tgtFolder
if (name extension of www) = "jpg" then
exit repeat
else
set www to ""
end if

end repeat

if www is not "" then
set tgtFile to www as alias

tell application "Image Events"

set this_img to open tgtFile
set {_width, _height} to dimensions of this_img
if ((_width > 800) or (_height > 800)) then
scale this_img to size 800
end if

set ppp to name of tgtFolder as text
save this_img in file (indexpath & ppp & ".jpg") as JPEG
close this_img

end tell
end if
end repeat

tell application "Image Events" to quit


画像は各フォルダ内の名前順1枚目のjpgファイルを、縦横最長ピクセル固定に変換しています。変換対象や方法は色々工夫できますね。
AppleScriptのコンポーネントであるImage Eventsは地味な存在ですが、オプションが豊富なので画像ファイルを一括処理する用途にかなり役立つと思います。

コメント

コメントをどうぞ

※メールアドレスとURLの入力は必須ではありません。 入力されたメールアドレスは記事に反映されず、ブログの管理者のみが参照できます。

※なお、送られたコメントはブログの管理者が確認するまで公開されません。

名前:
メールアドレス:
URL:
コメント:

トラックバック

このエントリのトラックバックURL: http://darzilin.asablo.jp/blog/2013/04/27/6791284/tb

※なお、送られたトラックバックはブログの管理者が確認するまで公開されません。