【问题标题】:Remove song from iTunes playlist based on tab-separated list根据制表符分隔的列表从 iTunes 播放列表中删除歌曲
【发布时间】:2018-09-22 20:25:09
【问题描述】:

我如何使用 Applescript 从 myPlaylist 中删除任何歌曲,如果它们包含以制表符分隔的文件中包含的名称 + 艺术家 + 年份之一?

所以如果 myPlaylist 的曲目之一是:

'Greensleeves The Scorpions 1965'

并且制表符分隔的文本文件包含以下行:

绿袖子 1965 年的蝎子

它将从播放列表中删除曲目。此外,它必须是准确的标题,因为我的一些歌曲标题中有括号和奇数字符。

谢谢!

【问题讨论】:

  • 您对我在回答中提交的脚本的理解如何?我知道我没有添加任何内容,但是当然,除了脚本应该按照您的要求执行之外,没有太多要说的。如果有任何问题,请告诉我,我可以解决它们。我会等待您的反馈。

标签: applescript itunes


【解决方案1】:
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”

【讨论】:

  • 好的,我想这必须粘贴到终端?我这样做了,将属性更改为属性路径:“Macintosh\ HD/Applications/Automator\ stuff/01b\ iTunes\ Scripts/SL+.txt” 属性播放列表:“Test1” 但我得到了我认为是错误消息:- bash:告诉:找不到命令-bash:意外标记“其”附近的语法错误
  • 不,你为什么认为它必须粘贴到 Terminal 中?你要了一个 AppleScript——所以我给了你一个 AppleScript。将其粘贴到 脚本编辑器。并且不要转义 path 属性中的空格。
  • 好的,抱歉,这是因为我以前从未见过“使用应用程序”命令。我现在再试一次!
  • 所以我现在收到这条消息:'exists file "Macintosh HD/Applications/Automator stuff/01b iTunes Scripts/SL+.txt" --> false' 但它是纯文本文档,根据 finder它在那个位置。请参阅:“位置:/Applications/Automator stuff/01b iTunes 脚本”
  • 好的,在没有“Macintosh HD”的情况下试了一下,效果很好。谢谢!感谢您的帮助和您之前给我的快速回复。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-15
  • 2017-09-09
  • 2013-10-22
相关资源
最近更新 更多