首次applescript编码问题

首次applescript编码问题,applescript,Applescript,好吧,我承认,我不知道我在做什么。我从下载的脚本中借用了很多代码。我正试图找出我的代码到底出了什么问题。起初,它不会编译,然后我被骗到最后这样做(基本上是删除它说的任何错误) 现在,我的代码有超过2/3是灰色的,无法工作。因此,不用再多说了,这里是: property progress_factor : 200 property separator : "-" tell application "iTunes" display dialog "\"Create Artist Folde

好吧,我承认,我不知道我在做什么。我从下载的脚本中借用了很多代码。我正试图找出我的代码到底出了什么问题。起初,它不会编译,然后我被骗到最后这样做(基本上是删除它说的任何错误)

现在,我的代码有超过2/3是灰色的,无法工作。因此,不用再多说了,这里是:

property progress_factor : 200
property separator : "-"
tell application "iTunes"

    display dialog "\"Create Artist Folder\"

    set lib to library playlist 1
    set numAllTracks to (get count of lib's file tracks)
    set everyPlaylist to (get name of every user playlist)

    set the count to 0

    set ofi to fixed indexing
    set fixed indexing to true

    try
        with timeout of 300000 seconds
            repeat with i from 1 to numAllTracks

                set thisTrack to (get a reference to file track i of lib)

                tell this Track to set {art, alb, dbid} to {get Artist as string, get database ID}

                if (art is not) then
                    set new_playlist_name to (art) as text
                else if
                    set new_playlist_name to " * "
                end if

                --make new playlist if it doesn't exist
                if everyPlaylist does not contain (new_playlist_name as text) then
                    set newPlaylist to (make playlist with properties {name:new_playlist_name})
                    set end of everyPlaylist to new_playlist_name
                end if
            -- Cycle through playlists of main library
                set thisPlaylist to (get a reference to file playlist i of lib)

            -- get Playlist properties
                tell thisPlaylist to set {art} to {get artist as string, get database ID} 

            -- Folder Playlist to put Playlist
                if (art is not) then
                    set new_folderplaylist_name to (art) as text
                else if
                    set new_FolderPlaylits_name to " * various or unnamed

    -- make new Folder Playlist if it doesn't exist
    if everyFolderPlaylist does not contain (new_folderplaylist_name as text) then
        set newFolderPlaylist to (make FolderPlaylist with properties {name:new_folderplaylist_name})
    end if
    set thecount to thecount + 1


    set fixed indexing to ofi
    if frontmost then
        if gave up of (display dialog "Done" buttons {"Yay!"} ¬
            default button 1 with icon 1 giving up after 300) then error number -128
    end if
end tell
我真的很感激每一点帮助。我也意识到这在新的iTunes中不是一个完全必要的功能,但我真的很想写我自己的

谢谢

试试这个:

property progress_factor : 200
property separator : "-"
tell application "iTunes"

    display dialog "Create Artist Folder"

    set lib to library playlist 1
    set numAllTracks to (get count of lib's file tracks)
    set everyPlaylist to (get name of every user playlist)

    set the count to 0

    set ofi to fixed indexing
    set fixed indexing to true

    try
        with timeout of 300000 seconds
            repeat with i from 1 to numAllTracks

                set thisTrack to (get a reference to file track i of lib)

                tell thisTrack to set {art, alb, dbid} to {get artist as string, get database ID}

                if (art is not "") then
                    set new_playlist_name to (art) as text
                else
                    set new_playlist_name to " * "
                end if

                --make new playlist if it doesn't exist
                if everyPlaylist does not contain (new_playlist_name as text) then
                    set newPlaylist to (make playlist with properties {name:new_playlist_name})
                    set end of everyPlaylist to new_playlist_name
                end if
                -- Cycle through playlists of main library
                set thisPlaylist to (get a reference to file playlist i of lib)

                -- get Playlist properties
                tell thisPlaylist to set {art} to {get artist as string, get database ID}

                -- Folder Playlist to put Playlist
                if (art is not "") then
                    set new_folderplaylist_name to (art) as text
                else
                    set new_FolderPlaylits_name to " * "
                end if
            end repeat
        end timeout
    end try

    -- make new Folder Playlist if it doesn't exist
    if everyFolderPlaylist does not contain (new_folderplaylist_name as text) then
        set newFolderPlaylist to (make FolderPlaylist with properties {name:new_folderplaylist_name})
    end if
    set thecount to thecount + 1


    set fixed indexing to ofi
    if frontmost then
        if gave up of (display dialog "Done" buttons {"Yay!"} ¬
            default button 1 with icon 1 giving up after 300) then error number -128
    end if
end tell

长话短说,你忘了放一堆
end
语句,还漏掉了几句结束语。

脚本的预期行为是什么?究竟发生了什么?