好吧,不可否认,我不知道我在做什么。我从我下载的脚本中借了很多代码。我想弄清楚我的代码到底出了什么问题。起初,它不会编译,然后我欺骗最终做到这一点(基本上删除它说的任何错误)
现在,超过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中完全必要的功能,但我真的想写自己的功能。
谢谢!
答案 0 :(得分:0)
试试这个:
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
陈述,而你错过了几个收尾报价。