1

このアップルスクリプト (Snow Leopard で動作していた) が 10.7 Lion で動作しなくなった理由を教えてください。

各アルバム フォルダから「folder.jpg」という名前のファイルを、iTunes で選択した mp3 の ID3 タグにコピーしようとしています。

property tempfile : ((path to temporary items as string) & "itunespicturefile_temporaire.pict")
global vPictFolder


tell application "iTunes"
    set v_TrackSelection to selection
    if v_TrackSelection is not {} then
        repeat with vTrack in v_TrackSelection
            set vPictFolder to my (ParentFromPath(location of vTrack as string)) as text
            set thisPict to my getpictData("folder.jpg")
            if thisPict is not "" then
                delete artworks of vTrack
                set data of artwork 1 of vTrack to (thisPict)
            end if
        end repeat
    else
        display dialog ("select tracks first !")
    end if
end tell

on getpictData(vAlbumpictName)
    tell application "Finder" to tell file vAlbumpictName of folder vPictFolder to if exists then
        set t_file to it as string
    else
        display dialog vPictFolder & vAlbumpictName
        return ""
    end if
    do shell script "/opt/local/bin/convert " & quoted form of POSIX path of t_file & " " & quoted form of POSIX path of tempfile
    display dialog "ok"
    return read (tempfile as alias) from 513 as picture
end getpictData

on ParentFromPath(thePath)
    set wantPath to true
    set thePath to (thePath as text)
    set saveDelim to AppleScript's text item delimiters
    set AppleScript's text item delimiters to {":"}
    set pathAsList to text items of thePath
    if the last character of thePath is ":" then
        set idx to (the number of text items in thePath) - 2
    else
        set idx to -2
    end if
    if wantPath then
        set folderName to ((text items 1 through idx of pathAsList) as text) & ":"
    else
        set folderName to item idx of pathAsList
    end if
    set AppleScript's text item delimiters to saveDelim
    return folderName
end ParentFromPath
4

1 に答える 1

1

画像形式 (" .pict ") は、Lion 以降の OS ではサポートされていないためです。この用語pictureを使用して画像ファイル (JPEG、PNG、...) を読み取ることができます。形式は形式ではPictureなく、ファイルの元の形式になります。

tell application "iTunes"
    set v_TrackSelection to selection
    if v_TrackSelection is not {} then
        repeat with vTrack in v_TrackSelection
            set vPictFolder to my (ParentFromPath(location of vTrack as string)) as text
            set thisPict to my getpictData(vPictFolder & "folder.jpg")
            if thisPict is not "" then
                delete artworks of vTrack
                set data of artwork 1 of vTrack to (thisPict)
            end if
        end repeat
    else
        display dialog ("select tracks first !")
    end if
end tell

on getpictData(tFile)
    try
        return (read (tFile as alias) as picture)
    end try
    display dialog tFile
    return "" -- not exists
end getpictData
于 2012-10-13T22:49:08.977 に答える