2013-06-01 38 views
0

所以,我有這樣的:移動電影,並與榛子系列,AppleScript的錯誤

on hazelProcessFile(theFile) 
    set text item delimiters to ":" 
    set filename to last text item of (theFile as text) 
    set text item delimiters to "." 
    if filename contains "." then 
     set base to text items 1 thru -2 of filename as text 
     set extension to "." & text item -1 of filename 
    else 
     set base to filename 
     set extension to "" 
    end if 
    set text item delimiters to {"WEB.DL.DD5.1.H.264.HWD", "WEB-DL.AAC2.0.H.264-NTb", "WEB-DL.DD5.1.H.264-CtrlHD", "WEB.DL.DD5.1.H.264", "PMP", "720p", "HDTV", "x264", "IMMERSE", "-", "E01", "…", "E02", "EVOLVE", "DIMENSION", "E03", "E04", "E05", "E06", "E07", "E08", "E09", "E10", "E11", "E12", "E13", "E14", "E15", "E16", "E17", "E18", "E19", "E20", "E21", "E22", "E23", "E24", "E25", "E26", "E27", "E28", "E29", "E30", "2012", "2013", "2014", "2015", "2016", "FoV", "FOV", "fov", "1080p", "X264", "AFG", "afg", "xvid", "XviD", "XVID", "INTERNAL", "PROPER", "FQM", "fqm", "LOL", "lol", "REWARD", "reward", "WEB", "DL", "AAC2", "H.264", "NTb", "CtrlHD", "DD5", "eztv", "EZTV", "WEB", "VTV", "mSD", "CTU", "hdtv", "evolve", "immerse", "+", "PublicHD", "HWD"} 
    set ti to text items of base 
    set text item delimiters to "" 
    set newbase to ti as text 
    set newbase to Replace(newbase, "S0", "Season ") 
    set newbase to Replace(newbase, "S1", "Season 1") 
    set newbase to Replace(newbase, "S2", "Season 2") 
    set newbase to Replace(newbase, ".", " ") 
    set newbase to Replace(newbase, " ", "") 
    set newbase to Replace(newbase, " ", "") 
    set newbase to Replace(newbase, " ", "") 
    set folderLocation to "/Volumes/LaCie/Midia/Series" 
    set folderName to newbase as text 
    tell application "Finder" 
     if newbase contains "Season" then 
      if not (exists folder (POSIX file "/Volumes/LaCie/Midia/Series/" & newbase as text)) then 

       -- make new folder at POSIX file "/Volumes/LaCie/Midia/Series/" with properties {name:newbase as text} 
       -- move theFile to POSIX file "/Volumes/LaCie/Midia/Series/" & newbase as text 
       do shell script "d=/Volumes/LaCie/Midia/Series/" & quoted form of newbase & " 
       mkdir -p \"$d\" 
       mv " & quoted form of POSIX path of theFile & " $d" 



      else 
       -- move theFile to POSIX file "/Volumes/LaCie/Midia/Series/" & newbase as text 
       do shell script "d=/Volumes/LaCie/Midia/Series/" & quoted form of newbase & " 
       mv " & quoted form of POSIX path of theFile & " $d" 

       set name of result to newbase 
      end if 
     else 
      -- move theFile to POSIX file "/Volumes/LaCie/Midia/Filmes/" 
      do shell script "mv " & quoted form of POSIX path of theFile & " /Volumes/LaCie/Midia/Filmes/" 
     end if 
    end tell 
end hazelProcessFile 

on Replace(input, x, y) 
    set text item delimiters to x 
    set ti to text items of input 
    set text item delimiters to y 
    ti as text 
end Replace 

我在它suposed創建一個文件夾,移動文件(特別是部分得到一個錯誤mv命令)。 該腳本是從一個榛子規則激活,它應該發現,如果一個文件是電影或電視節目集(清理文件名),並將其移動到相應的文件夾(如果它不存在,它會創建文件夾) 任何想法? 謝謝!

+0

可能重複[AppleScript的錯誤,而試圖與榛移動文件(http://stackoverflow.com/questions/16501501/applescript-error-while-trying-to-move -files-with-hazel) – user495470

+0

以前的後續問題:http://stackoverflow.com/questions/16680911/error-making-folders-in-applescript – user495470

+0

是的!任何想法@勞裏?你還沒有回覆其他帖子... –

回答

0

嘗試:

set d to quoted form of ("/Volumes/LaCie/Midia/Series/" & newbase) 
do shell script "mkdir -p " & d & " ; mv " & quoted form of (POSIX path of theFile) & space & d