カテゴリー
Mac

Apertureプロジェクトの自動分割

Aperture 最大の不満がこの iPhoto にあった機能がないこと(結合はあるのに!!)。複数のカメラで撮った写真を日付毎に分けてるので、読み込み時のプロジェクト分割だと同じ日付で複数のプロジェクトが出来ちゃうし、かと言って手動で分割はダルくてやってらんない。

とゆーことで、AppleScript Language GuideAperture 3 AppleScript Referenceを見ながら AppleScript と格闘してたらそれっぽいものが出来上がったのでメモ。でももっと上手い解決方法があったら教えて偉い人!

(2011/8/26 追記)速くできるんじゃないか、とちょっと頑張ってみたバージョンはこちら

適当に写真を選択した状態でこのスクリプトを実行すると

  1. 撮影日のプロジェクト(YYYY年MM月DD日)が無かったら作成
  2. 写真を撮影日のプロジェクトに移動

とゆー感じに動きます、多分…。 AppleScript はよくわからないのですが、撮影日のプロジェクトはフォルダの配下にあっても認識するみたいなので、プロジェクト作成後は適当な場所に動かしてもプロジェクトを作ることはないみたい…?

ライブラリにあるプロジェクトを全部なめるのでライブラリがデカければデカいほど遅くなるのはお約束 :) 。というかもうちょっとスマートに書けないのかなー

tell application "Aperture"
  set imageSel to (get selection)
  if imageSel is {} then
    error "Please select an image."
  else
    repeat with i from 1 to count of imageSel
      tell (item i of imageSel)
        set imgy to round (value of EXIF tag "CaptureYear") as number
        set imgm to round (value of EXIF tag "CaptureMonthOfYear") as number
        set imgd to round (value of EXIF tag "CaptureDayOfMonth") as number
        if length of (imgm as string) = 1 then
          set imgm to "0" & imgm
        end if
        if length of (imgd as string) = 1 then
          set imgd to "0" & imgd
        end if
        set projname to (imgy as string) & "年" & (imgm as string) & "月" & (imgd as string) & "日"
      end tell
      tell library 1
        set flagProj to false
        set projSel to get name of every project
        repeat with existProj in projSel
          if contents of existProj is equal to projname then
            set flagProj to true
            exit repeat
          end if
        end repeat
        if flagProj is false then
          make new project with properties {name:projname}
        end if
      end tell
      move item i of imageSel to project projname
    end repeat
  end if
end tell

コメントを残す