Applescript上的错误消息重复并重命名

时间:2014-11-29 15:01:00

标签: applescript duplicates

我使用这个AppleScript使用小型参考文件“Archived.m4v”将剧集存档到新位置,然后将其重命名为剧集名称。 我在OSX Yosemite中不断收到错误信息,而在OSX Mavericks下它完美无缺。

错误"The variable NewFile is not defined." number -2753 from "NewFile"

与这样的脚本相关的所有问题都有相同的代码,所以我在这里疯了......

set TheFile to alias "Video:Tools:Archived.m4v"
set Destination to alias "Video:Archives:WIP - TV Shows:"}
set Source to (choose folder with prompt "Pick the folder with the tv episodes...")

tell application "Finder"
    set theList to every file of entire contents of Source
    repeat with thisFile in theList
        set {tid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "."}
        set FileName to (text items 1 thru -2 of (get name of thisFile)) as text
        set NewFile to duplicate TheFile to folder Destination with replacing
        set NewFile's name to (FileName & ".m4v")
    end repeat
end tell

1 个答案:

答案 0 :(得分:1)

我看到的唯一明显的错误是你的重复行。目的地已经是一个别名,所以它不应该有"文件夹"在它面前。我现在无法对此进行测试,但请尝试删除"文件夹"看看是否有帮助。

如果没有解决问题,唯一要尝试的是将最后一行更改为...

set name of file ((destination as text) & "Archive.m4v") to (FileName & ".m4v")