Applescript:Finder收到错误:AppleEvent处理程序失败

时间:2012-01-13 09:24:05

标签: applescript finder

我有这个脚本设置或重命名我的torrent文件夹,但它不断给我这个奇怪的finder错误。当我不从文本文件中读取它时,它可以工作,但我需要这样做,所以我不需要一直选择文件夹:请帮助:

set read_folder to read (POSIX path of "/.torrentcleanup-prefs.txt") as text
set autofolder to (POSIX file read_folder)
set folderlist to ("")
tell application "Finder" to set folderlist to (get name of folders of folder autofolder)
repeat with i in folderlist
    set dfilepath to (POSIX path of ((autofolder & i) as text))
    set dfoldername to quoted form of POSIX path of dfilepath
    set dfolder to i
    set dmovie to quoted form of (text 1 thru ((length of dfolder) - 7) of dfolder as text)
    try
        do shell script "cd " & dfoldername & "; mv ./*.mkv ../" & dmovie & ".mkv"
    end try
    try
        do shell script "cd " & dfoldername & "; mv ./*.mp4 ../" & dmovie & ".mp4"
    end try
    do shell script "rm -r " & dfoldername & ""
end repeat

顺便说一下,“/。torrentcleanup-prefs.txt”的内容是:

/ Users / student / Desktop / FIX ME NOW / Test Folder /

1 个答案:

答案 0 :(得分:0)

我没有查看你的整个脚本,但你在第一行读错了文件。你需要这样做。所以用这两个替换你的第一行......

set myFile to "/.torrentcleanup-prefs.txt"
set read_folder to read (POSIX file myFile)