directory - Error making folders in Applescript -
so, i'm getting error while running this:
on hazelprocessfile(thefile) set text item delimiters ":" set filename last text item of (thefile text) set text item delimiters "." if filename contains "." set base text items 1 thru -2 of filename text set extension "." & text item -1 of filename else set base filename set extension "" end if set text item delimiters {"720p", "hdtv", "x264", "immerse", "-", "e01", "…", "e02", "evolve"} set ti text items of base set text item delimiters "" set newbase ti text set newbase replace(newbase, "s0", "season ") set newbase replace(newbase, ".", " ") set newbase replace(newbase, " ", "") set newbase replace(newbase, " ", "") set folderlocation "/volumes/lacie/midia/series/" set foldername newbase text tell application "finder" if newbase contains "season" if not (exists folder (posix file "/volumes/lacie/midia/series/" & newbase text)) set p path "/volumes/lacie/midia/series/" --make new folder @ p properties {name:newbase} make new folder properties {name:foldername, location:p} else move thefile posix file "/volumes/lacie/midia/series/" & newbase text set name of result newbase end if else move thefile posix file "/volumes/lacie/midia/filmes/" end if end tell end hazelprocessfile on replace(input, x, y) set text item delimiters x set ti text items of input set text item delimiters y ti text end replace specifically in part suposed create folder if doesnt exists (its purpose automatically sort tv series episodes).
log file:
nslocalizeddescription = "finder got error: can\u2019t make \"/volumes/lacie/midia/series/\" type constant."; nslocalizedfailurereason = "can\u2019t make \"/volumes/lacie/midia/series/\" type constant."; osascripterrorappaddresskey = "<nsappleeventdescriptor: [0x0,c00c \"finder\"]>"; osascripterrorappnamekey = finder; osascripterrorbriefmessagekey = "can\u2019t make \"/volumes/lacie/midia/series/\" type constant."; osascripterrorexpectedtypekey = "<nsappleeventdescriptor: 'enum'>"; osascripterrormessagekey = "finder got error: can\u2019t make \"/volumes/lacie/midia/series/\" type constant."; osascripterrornumberkey = "-1700"; osascripterroroffendingobjectkey = "<nsappleeventdescriptor: 'utxt'(\"/volumes/lacie/midia/series/\")>"; osascripterrorrangekey = "nsrange: {0, 0}"; any ideas? thanks!
edit:
so, @lauri helped me moving part, thing wrong file copied, not moved, meaning original file stays in same place. want trashed or copleteley moved. ideas?
edit 2:
so, i've implemented @lauri suggested , still have error (on mv command), ideas?
on hazelprocessfile(thefile) set text item delimiters ":" set filename last text item of (thefile text) set text item delimiters "." if filename contains "." set base text items 1 thru -2 of filename text set extension "." & text item -1 of filename else set base filename set extension "" end if set text item delimiters {"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 text items of base set text item delimiters "" set newbase ti text set newbase replace(newbase, "s0", "season ") set newbase replace(newbase, "s1", "season 1") set newbase replace(newbase, "s2", "season 2") set newbase replace(newbase, ".", " ") set newbase replace(newbase, " ", "") set newbase replace(newbase, " ", "") set newbase replace(newbase, " ", "") set folderlocation "/volumes/lacie/midia/series" set foldername newbase text tell application "finder" if newbase contains "season" if not (exists folder (posix file "/volumes/lacie/midia/series/" & newbase text)) -- make new folder @ posix file "/volumes/lacie/midia/series/" properties {name:newbase text} -- move thefile posix file "/volumes/lacie/midia/series/" & newbase text 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 posix file "/volumes/lacie/midia/series/" & newbase text shell script "d=/volumes/lacie/midia/series/" & quoted form of newbase & " mv " & quoted form of posix path of thefile & " $d" set name of result newbase end if else -- move thefile posix file "/volumes/lacie/midia/filmes/" 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 x set ti text items of input set text item delimiters y ti text end replace
replace path to posix file , use at specifier location:
tell application "finder" make new folder @ posix file "/tmp" properties {name:"new folder"} end tell fwiw, question follow-up applescript error while trying move files hazel.
apparently move command copies files when target on different volume. use shell script instead:
if newbase contains "season" shell script "d=/volumes/lacie/midia/series/" & quoted form of newbase & " mkdir -p \"$d\" mv " & quoted form of posix path of thefile & " $d" else shell script "mv " & quoted form of posix path of thefile & " /volumes/lacie/midia/filmes/" end if
Comments
Post a Comment