如果歌曲包含标签分隔的文件中的名称+艺术家+年份,我如何使用Applescript从myPlaylist中删除任何歌曲?
因此,如果myPlaylist的第一轨是:
“绿衣天蝎座1965年”
选项卡分隔的文本文件包含以下行:
格林斯利夫斯1965年天蝎座
它将从播放列表中删除该轨道。而且,它需要确切的标题,因为我的一些歌曲标题中有括号和奇怪的字符。
谢谢!
发布于 2018-09-22 22:44:20
use application "iTunes"
use scripting additions
--------------------------------------------------------------------------------
###USER-DEFINED PROPERTIES: path, playlist
property path : "~/Desktop/trackdelete.list"
property playlist : "myPlaylist"
--------------------------------------------------------------------------------
property text item delimiters : tab
--------------------------------------------------------------------------------
###IMPLEMENTATION
#
#
tell the deleteList
if not (its file exists) then return -1
read
repeat with i from 1 to the length of its list
set [its name, its artist, its year] to ¬
[text item 1, text item 2, text item 3] of ¬
item i of its list
delete (playlistItem's track where ¬
name = deleteList's name and ¬
artist = deleteList's artist and ¬
year = deleteList's year)
end repeat
end tell
--------------------------------------------------------------------------------
###SCRIPT OBJECTS & HANDLERS
#
#
script playlistItem
property playlist : a reference to the playlist named (my playlist)
property track : a reference to every track of my playlist
end script
script deleteList
property application : application "System Events"
property file : a reference to file (my path) of my application
property list : null
property name : null
property artist : null
property year : null
to read
tell AppleScript to read (my file as alias)
set my list to the result's paragraphs
end read
end script
---------------------------------------------------------------------------❮END❯系统信息: AppleScript版本:"2.7",系统版本:"10.13.6“
https://stackoverflow.com/questions/52460598
复制相似问题