Alle Posts mit Tag: AppleScript

Am Wochenende habe ich mich mal etwas mit AppleScript beschaeftigt. Es ging mir ein wenig auf den Keks, dass die Albumcovers die aus iTunes gezogen werden nicht im ID-Tag gespeichert werden, sondern in der iTunes Library Database und den dazu gehoerenden Artwork Ordner. Bei der Aktion kam dann das unten aufgefuehrte Skript raus, dass aus den selektierten Liedern in iTunes die Cover extrahiert und in den zu dem Lied dazugehoerenden Ordner als JPG Datei abspeichert.


(*
Will save covers from selected songs in iTunes into
the album folder which belongs to the selected songs.
*)

tell application “iTunes”
  set lastAlbumName to “”

  repeat with mySong in (selection of front window)
   set songLocation to location of mySong
   set albumArtwork to raw data of first artwork of mySong
   set albumName to album of mySong

   if not (lastAlbumName is albumName) then
    tell application “Finder”
    set folderLocation to (get folder of songLocation as text)
    set coverLocation to folderLocation & “cover.jpg”

     (*
     If a cover is already in the folder, do nothing
     *)
     if not (coverLocation exists) then
      set albumFile to open for access coverLocation with write permission
      write albumArtwork to albumFile
      close access albumFile

      set lastAlbumName to albumName
     end if
    end tell
   end if
  end repeat
end tell

Fuer den oben dargestellten Code uebernehme ich keinerlei Verantwortung oder Haftung fuer die Korrektheit, Vollstaendigkeit
bzw. falls irgendwelche Schaeden durch den Code entstehen sollten.