Delete empty folders

All your suggestions, requests and ideas for future development
Post Reply
pr1nc1p3
Posts: 8
Joined: 22 Jan 2012, 14:09

Delete empty folders

Post by pr1nc1p3 »

When move all files from a directory is very useful delete that folder recursive like Musicbrainz Picard.
User avatar
rednoah
The Source
Posts: 22994
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Delete empty folders

Post by rednoah »

I don't really plan on doing any kinda of "delete" operations. Empty folders / jpg / NFO / etc. But there FileBot scripts for that if you want.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 22994
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Delete empty folders

Post by rednoah »

Thought about adding this, but there's conflicts with people renaming e.g. .../Incoming/*.avi which would result in FileBot deleting their default incoming folder (even if empty still annoying). So while it makes sense for some cases, it's annoying for others, and it's pretty hard to auto-detect which one it is.
:idea: Please read the FAQ and How to Request Help.
thequestion
Posts: 8
Joined: 18 Dec 2011, 17:52

Re: Delete empty folders

Post by thequestion »

I would rather see this in a filebot script, which is run after filebot has ben running, sort of cleanup script if a user wants to delete old empty folders etc.
User avatar
rednoah
The Source
Posts: 22994
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Delete empty folders

Post by rednoah »

Well, i don't plan on adding that to the GUI and i think a "default shutdown script" would be overkill as well. Because one can just do a script it like filebot && filebot -script myPersonalCleanup.groovy but deleting empty folder manually takes like 1 second.
:idea: Please read the FAQ and How to Request Help.
thequestion
Posts: 8
Joined: 18 Dec 2011, 17:52

Re: Delete empty folders

Post by thequestion »

yes I was thinking more like:

Code: Select all

#!/bin/bash
#

filebot -- "params I want to use"

find /dir/to/my/movies/ -type d -name '*' -exec rmdir {} \;
Not a working script but an idea, also rmdir only works in empty folders.
User avatar
rednoah
The Source
Posts: 22994
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Delete empty folders

Post by rednoah »

Yep, something like that is easy to do and everybody can customize it to exactly what they want. Though I'd do the clean up via

Code: Select all

filebot -script http://filebot.sf.net/scripts/cleaner.groovy -trust-script /path/to/my/downloads/
hehe :P
:idea: Please read the FAQ and How to Request Help.
pr1nc1p3
Posts: 8
Joined: 22 Jan 2012, 14:09

Re: Delete empty folders

Post by pr1nc1p3 »

Delete operations+ housemade scripts+novice users = Nuke file systems.

Maybe this is the only delete operation filebot must do auto.
User avatar
rednoah
The Source
Posts: 22994
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Delete empty folders

Post by rednoah »

That's why people should just use my predefined stuff:

Code: Select all

filebot -script fn:cleaner ...
Being able to modify things is just an added bonus.
:idea: Please read the FAQ and How to Request Help.
vletroye
Posts: 40
Joined: 27 Sep 2014, 11:25

Re: Delete empty folders

Post by vletroye »

+1 on Pr1nc1p3's principe :D

Fortunately I tried first in test mode: filebot.exe -script fn:cleaner "V:\Path\To\MyMovies" --action test 2> filebot-error.log 1> filebot.log

But apparently, by default, filebot wanted to delete all my folders still containing .iso, .avi or .mp4 :(

Ex.: filebot.log

Code: Select all

Delete V:\Path\To\MyMovies\Tactical Force (2011)\Tactical Force (2011) [1080p.x264.].iso
Delete V:\Path\To\MyMovies\Taxi 1 (1998)\Taxi (1998) [480p.DivX.MP3].avi
Delete V:\Path\To\MyMovies\Taxi 2 (2000)\Taxi 2 (2000) [360p.DivX.MP3].avi
Delete V:\Path\To\MyMovies\The Artist (2011)\The Artist (2011) [1080p.x264.AAC].mp4
Delete V:\Path\To\MyMovies\The Experiment (2009)\L'Expérience (2010) [480p.XviD.AC3].avi
Delete V:\Path\To\MyMovies\The Master (2012)\The Master (2012) [480p.XviD.MP3].avi
Wierd as avi and iso are recognized by filebot as movies, isn't ?

Extrapolating the doc here, I tried to delete only the empty folders, using an empty list of extensions, but without more success: filebot.exe -script fn:cleaner "V:\Path\To\MyMovies" --action test --def "exts=" 2> filebot-error.log 1> filebot.log

I think it's time for me to go to sleep :cry:
User avatar
rednoah
The Source
Posts: 22994
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Delete empty folders

Post by rednoah »

That can't happen. Unless the file size of the video file is less than 20 MB.

@see https://github.com/filebot/scripts/blob ... ner.groovy

Looks like you have organized and messy files/folder all in the same structure. You have experienced one of the many reasons why this is a bad idea.
:idea: Please read the FAQ and How to Request Help.
vletroye
Posts: 40
Joined: 27 Sep 2014, 11:25

Re: Delete empty folders

Post by vletroye »

Well... I have organized all my movies for Plex Media Server...
So, as far as movies are concerned (opposite to series), there is only one movie per folder and all the folders are in one common root folder.
I think that this is ok?! Otherwise, I would be in trouble with Plex too.

A few weeks ago, I discovered filebot and renamed all my movies with their French title. It went very well 8-)
I wanted now to rename also the folders as I noticed that some of them were still in English instead of French.
I clearly understand now that I should move them to another root folder instead...
But still, the avi and iso candidates to be deleted are much larger than 20MB ?!

=> I will check asap if this can be due to a bug with my "File System" (FlexRaid) returning the wrong size to filebot...
Indeed, the files renamed by filebot used to be displayed as 0 Bytes once moved with my "File System", due to an alternate stream hiding the main file stream (FYI: possibly see my report here http://forum.flexraid.com/index.php?topic=4166.0).

Is by any chance such an alternate stream added into the files when renaming movies with filebot ?
User avatar
rednoah
The Source
Posts: 22994
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Delete empty folders

Post by rednoah »

Quick look at the code:

Code: Select all

if ((f.isVideo() || f.isAudio()) && fsize < minsize)
	return true
So yes, if file size is 0 then the cleaner script will think that these files are useless and should be deleted. That's why deleting things automatically is a bad bad idea!!! :lol:

I think you can pass in --def minsize=0 so to ensure that fsize < minsize is never true... better try with --action test first!!!

PS: FileBot does use alternative streams / xattr / extended attributes to store metadata.

@see viewtopic.php?f=3&t=2047
:idea: Please read the FAQ and How to Request Help.
vletroye
Posts: 40
Joined: 27 Sep 2014, 11:25

Re: Delete empty folders

Post by vletroye »

I confirm my the FileSystem his hiding the main stream and returning the size of the alternate stream instead... (by accident, I have only alternate streams for avi and iso that I renamed recently with filebot).

A fix is available for this FileSystem.. So, "tout va bien" :P
Post Reply