2010-07-07 73 views
4

我正在尝试编写一个iTunes脚本,将所选曲目移至另一个文件夹,然后在iTunes中更新它们的位置。使用AppleScript将路径更改为iTunes中的文件

的整个流程是这样的:

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

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

有人知道如何去做这件事吗?

回答

4

我想通了。我有一个不同的错误,让我觉得这很难。以下是我得到它的工作:

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 
+2

我不会这样做。 “选择”是项目列表。如果您在iTunes中选择了多首歌曲,列表中可能会有很多项目。你需要定位列表中的第一个项目,如下所示:设置(获取选择)的项目1的位置为 regulus6633 2010-07-07 23:10:25

+1

是的,好点。我更新了我的答案 – finiteloop 2010-07-08 03:08:04

1

其基本思想是将每个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 
+0

嗯,我试运行,但下面的错误弹出:错误“的iTunes得到了一个错误:无法使一些数据到预期的类型。”号码-1700到项目 – 2017-08-01 21:23:09