提供删除某些内容的脚本总是非常危险的。
因为你的请求有点模棱两可
至少有一集被标记为未观看
和
一集,即使该节目被标记为观看或未观看
脚本将删除播放列表中所有观看的剧集
TV Shows
如果至少有一集未播出。
所有未播出的剧集
不
删除。
有两个脚本,一个用于测试,另一个用于删除。
脚本#1没有删除任何内容
但是显示应该被删除的项目的列表。
tell application "iTunes"
set watchedEpisodes to tracks of playlist "TV Shows" whose unplayed is false and played count > 0
set unwatchedEpisodes to tracks of playlist "TV Shows" whose unplayed is true
if (count unwatchedEpisodes) > 0 then
set trackNames to {}
repeat with anEpisode in watchedEpisodes
set end of trackNames to ((name of anEpisode) as text) & " of show " & show of anEpisode
end repeat
set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
display dialog trackNames as text
set AppleScript's text item delimiters to TID
end if
end tell
请仔细检查输出
脚本#2删除符合条件的项目
tell application "iTunes"
set watchedEpisodes to tracks of playlist "TV Shows" whose unplayed is false and played count > 0
set unwatchedEpisodes to tracks of playlist "TV Shows" whose unplayed is true
if (count unwatchedEpisodes) > 0 then
repeat with anEpisode in watchedEpisodes
delete anEpisode
end repeat
end if
end tell