Removing input directories
Posted: 26 Oct 2012, 01:38
This is the workflow I'm trying to implement.
I'm downloading all my stuff in an external system and everything is setup so I just mirror whatever files have been downloaded during the day
Once the files are in my local system I process them with the utorrent-postprocess script.
The input folder has stuff like this:
drwxr-xr-x+ 1 stickman None 0 Oct 26 03:01 Elementary.S01E04.720p.HDTV.X264-DIMENSION
drwxr-xr-x+ 1 stickman None 0 Oct 26 03:03 Hunted.S01E04.720p.HDTV.x264-TLA
drwxr-xr-x+ 1 stickman None 0 Oct 26 03:04 The.Big.Bang.Theory.S06E05.720p.HDTV.X264-DIMENSION
drwxr-xr-x+ 1 stickman None 0 Oct 26 03:10 Los.Serrans.S06E05.720p.HDTV.X264-PANDA
Inside each folder there are compressed files and once uncompressed the file structure is like:
<base_dir>/The.Big.Bang.Theory.S06E05.720p.HDTV.X264-DIMENSION/whatever_name_they_choose/The.Big.Bang.Theory.S06E05.720p.HDTV.X264-DIMENSION.mkv
I'd like to delete the input folder ONLY if filebot succeeded identifying the episode and moving it to the output folder, so I just keep those files filebot failed to identify.
For instance, in the given example the show Los.Serrans.S06E05.720p.HDTV.X264-PANDA will fail and I wouldn't like for it to be removed.
I've thought about adding a closure using getRenameLog
but in this way I'll be just deleting:
instead of
I don't know if this is the right approach or if there is any other way to do it.
Any ideas?
I'm downloading all my stuff in an external system and everything is setup so I just mirror whatever files have been downloaded during the day
Once the files are in my local system I process them with the utorrent-postprocess script.
The input folder has stuff like this:
drwxr-xr-x+ 1 stickman None 0 Oct 26 03:01 Elementary.S01E04.720p.HDTV.X264-DIMENSION
drwxr-xr-x+ 1 stickman None 0 Oct 26 03:03 Hunted.S01E04.720p.HDTV.x264-TLA
drwxr-xr-x+ 1 stickman None 0 Oct 26 03:04 The.Big.Bang.Theory.S06E05.720p.HDTV.X264-DIMENSION
drwxr-xr-x+ 1 stickman None 0 Oct 26 03:10 Los.Serrans.S06E05.720p.HDTV.X264-PANDA
Inside each folder there are compressed files and once uncompressed the file structure is like:
<base_dir>/The.Big.Bang.Theory.S06E05.720p.HDTV.X264-DIMENSION/whatever_name_they_choose/The.Big.Bang.Theory.S06E05.720p.HDTV.X264-DIMENSION.mkv
I'd like to delete the input folder ONLY if filebot succeeded identifying the episode and moving it to the output folder, so I just keep those files filebot failed to identify.
For instance, in the given example the show Los.Serrans.S06E05.720p.HDTV.X264-PANDA will fail and I wouldn't like for it to be removed.
I've thought about adding a closure using getRenameLog
Code: Select all
def deleteClos
deleteClos = { println "Dir ${it.canonicalPath}";
it.eachDir( deleteClos );
it.eachFile {
println "File ${it.canonicalPath}";
it.delete()
}
it.delete()
}
getRenameLog().each{ from, to ->
def f = new File("$from")
deleteClos( new File("$f.parent))
}
Code: Select all
<base_dir>/The.Big.Bang.Theory.S06E05.720p.HDTV.X264-DIMENSION/whatever_name_they_choose/
Code: Select all
<base_dir>The.Big.Bang.Theory.S06E05.720p.HDTV.X264-DIMENSION/
Any ideas?