Csv 使用制表符分隔的txt文件生成iTunes播放列表时,请检查重复项
我正在使用Applescript中的以下代码从一个选项卡分隔的.txt文件生成iTunes播放列表。但是,我想知道是否有办法让它在添加每个文件之前检查文件是否已经在目标播放列表中Csv 使用制表符分隔的txt文件生成iTunes播放列表时,请检查重复项,csv,applescript,itunes,Csv,Applescript,Itunes,我正在使用Applescript中的以下代码从一个选项卡分隔的.txt文件生成iTunes播放列表。但是,我想知道是否有办法让它在添加每个文件之前检查文件是否已经在目标播放列表中 set thisTSVFile to (choose file with prompt "Select the CSV file") readTabSeparatedValuesFile(thisTSVFile) set theList to readTabSeparatedValuesFile(
set thisTSVFile to (choose file with prompt "Select the CSV file")
readTabSeparatedValuesFile(thisTSVFile)
set theList to readTabSeparatedValuesFile(thisTSVFile)
tell application "iTunes"
set myPlaylist to playlist "InSLtxtLists"
set sourcePlaylist to playlist "Music"
end tell
repeat with i from 2 to number of items in readTabSeparatedValuesFile(thisTSVFile)
--gets first column
set theName to item 1 of item i of theList
--gets second
set theArtist to item 2 of item i of theList
tell application "iTunes"
try
duplicate (some track of sourcePlaylist whose name is theName and artist is theArtist) to myPlaylist
on error the errorMessage
set
end try
end tell
delay 0.1
end repeat
on readTabSeparatedValuesFile(thisTSVFile)
try
set dataBlob to (every paragraph of (read thisTSVFile))
set the tableData to {}
set AppleScript's text item delimiters to tab
repeat with i from 1 to the count of dataBlob
set the end of the tableData to (every text item of (item i of dataBlob))
end repeat
set AppleScript's text item delimiters to ""
return tableData
on error errorMessage number errorNumber
set AppleScript's text item delimiters to ""
error errorMessage number errorNumber
end try
end readTabSeparatedValuesFile
作为参考,.txt文件中的每一行的格式如下:
“Allo”Allo!Theme(David Croft&Roy Moore)Jack Emblow 1982
“iTunes”--您运行的是什么版本的macOS?无论如何,您需要将名称
的值与曲目名称
的a列表
进行比较,例如如果(播放列表的曲目名称myPlaylist“不包含名称然后…”
OS Mojave 10.14.6如果有帮助!那么在tell blocks@user3439894?周围包装一个“如果”块,或者我应该放在什么地方?if(播放列表的曲目名称myPlaylist)不包含名称然后复制(源播放列表的一些曲目,其名称是名称,艺术家是艺术家)到我的播放列表