语法错误预期行结束时发现未知令牌为文件夹操作编写Apple脚本

时间:2018-01-16 11:40:52

标签: macos applescript

enter image description here

对于我的生活,我无法弄清楚是什么导致了这个错误。我确保禁用智能引号,但不断收到相同的错误。该脚本本身旨在自动化手刹视频转换,不可否认,我是一个非常新的苹果脚本,但无法弄清楚是什么导致了这一点。任何帮助将不胜感激。

以下是完整的代码,以防它有用:

on adding folder items to this_folder after receiving these_items
    with timeout of (720 * 60) seconds
        tell application "Finder"
            --Get all MOV files that have no label color yet, meaning it hasn't been processed 
            set allFiles to every file of entire contents of ("Macintosh HD:Users:MacMini:Downloads:Downloaded" as alias) whose (name extension is "mov" and label index is 0)

            --Repeat for all files in above folder
            repeat with i from 1 to number of items in allFiles
                set currentFile to (item i of allFiles)

                try
                    --Set to gray label to indicate processing
                    set label index of currentFile to 7

                    --Assemble original and new file paths
                    set origFilepath to quoted form of POSIX path of (currentFile as alias)
                    set newFilepath to (characters 1 thru -5 of origFilepath as string) & "mp4'"

                    --Start the conversion
                    set shellCommand to "nice /Applications/HandBrakeCLI -i " & origFilepath & " -o " & newFilepath & " --preset=\"Fast 720p30\" --optimize ;"
                    tell current application
                        do shell script shellCommand
                    end tell

                    --Set the label to green in case file deletion fails
                    set label index of currentFile to 6

                    --Remove the old file
                    set shellCommand to "rm -f " & origFilepath
                    tell current application
                        do shell script shellCommand
                    end tell
                on error errmsg
                    --Set the label to red to indicate failure
                    set label index of currentFile to 2
                end try
            end repeat
        end tell
    end timeout
end adding folder items to

1 个答案:

答案 0 :(得分:0)

这是一个典型的副本&粘贴错误:

&amp;的<{>>所有次出现替换为&