Removing input directories

Any questions? Need some help?
Post Reply
stickman
Posts: 8
Joined: 22 Oct 2012, 21:48

Removing input directories

Post by stickman »

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

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))
}
but in this way I'll be just deleting:

Code: Select all

<base_dir>/The.Big.Bang.Theory.S06E05.720p.HDTV.X264-DIMENSION/whatever_name_they_choose/
instead of

Code: Select all

<base_dir>The.Big.Bang.Theory.S06E05.720p.HDTV.X264-DIMENSION/
I don't know if this is the right approach or if there is any other way to do it.

Any ideas?
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Removing input directories

Post by rednoah »

Keep track of everything seems a bit complicated though. Have you thought of running fn:cleaner once in a while?
http://filebot.sourceforge.net/forums/v ... &t=5#p1341

That script removes clutter files like .url, .nfo etc and left over folders but'll never touch any folders that contain at least one non-clutter (i.e. video) file. So if the video file has been moved away things will get removed, if the video is still there nothing will happen.
:idea: Please read the FAQ and How to Request Help.
Post Reply