【问题标题】:Changing the path to a file in iTunes with AppleScript使用 AppleScript 更改 iTunes 中文件的路径
【发布时间】:2011-03-13 01:23:55
【问题描述】:

我正在尝试编写一个 iTunes 脚本来获取所选曲目,将文件移动到我硬盘上的不同文件夹,然后更新它们在 iTunes 中的位置。

整体流程是这样的:

  1. 获取选择
  2. 确定选择路径
  3. 将项目移动到目的地
  4. 更新 iTunes 中的引用路径

我使用this question 的建议来获取 iTunes 中选择的路径,我将能够弄清楚如何将文件移动到我想要的位置,但是,现在我想告诉 iTunes文件路径实际上是其他地方。

有人知道怎么做吗?

【问题讨论】:

    标签: macos applescript itunes


    【解决方案1】:

    我想通了。我有一个不同的错误让我觉得这比它更难。这是我如何让它工作的:

      tell application "iTunes"
         set s to selection
            repeat with c in s
               if video kind of c is TV show then
                  set location of c to <destination directory>
                  <code to move file>
               end if
      end tell
    

    【讨论】:

    • 我不会这样。 “选择”是项目列表。如果您在 iTunes 中选择了不止一首歌曲,列表中可能会有很多项目。您需要像这样定位列表中的第一项:将((获取选择的第一项)的位置设置为
    【解决方案2】:

    基本思想是将每个file track 项的location 属性设置为其新的文件路径。例如:

    tell application "iTunes"
        tell its first browser window
            set currentTrack to first item of (get its selection)
            set location of currentTrack to POSIX file "/Users/nad/Music/movedfile.m4a"
        end tell
    end tell
    

    【讨论】:

    • 嗯,我尝试运行它,但弹出以下错误:错误“iTunes 出错:无法将某些数据转换为预期类型。”编号 -1700 到项目
    猜你喜欢
    • 2011-01-08
    • 1970-01-01
    • 2019-11-27
    • 2012-06-20
    • 1970-01-01
    • 2014-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多