Deleting Empty Folders (yeah, I know, I know...)

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

MoDementia
Posts: 1321
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Post by MoDementia »

Hahahaha, its skipping most of the folders in the log :)

Code updated: Includes confirmation on all deletes
Kilmatead
Posts: 206
Joined: Mon Apr 07, 2008 2:16 pm
Location: Dublin

Post by Kilmatead »

This is me being thick again. Sorry. :oops: Still complaining about permissions - whilst it is only too happy to delete it's own log now (before I can check it), nothing else is deleted. Must not be reading the names off the log correctly, as it never even gets to the confirmation bit.

Has VB always been this arcane to debug, or does MM just have a "One Size Fits All" scripting error policy? Odd.
Kilmatead
Posts: 206
Joined: Mon Apr 07, 2008 2:16 pm
Location: Dublin

Post by Kilmatead »

Ok, I've been digging. Let's see. Say my music folder is 'C:\Users\Kilmatead\Music':

In 'Sub DeleteFolders()'

Code: Select all

       If yCounter > 1 Then
         Set FolderProperties = FSO.GetFolder(Folder)
is causing the "Permissions" error as when yCounter = 2 it's trying to get the properties of the main User Account Folder (Kilmatead) - and it terminates - apparently this is a no-no, as any other folder check works fine ('Users' or 'Music'). Obviously the simple solution is just If yCount > 2 instead of 1 - but this might cause problems for people who keep their music on a drive other than C:.

My question is, exactly why did you create DeleteFolders() to parse out tmpArray at all? It seems to me as MoveDeleteFolders() already contains the necessary target in the Folder string - it could just do the existence check, size check, and kill it if it's truly evil.

Or am I missing something?

Or, indeed, if it must parse it, shouldn't it be parsing backwards from the innermost children to the parent, instead of parent to child?

Mustn't we all seek our own innermost child? :D
MoDementia
Posts: 1321
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Post by MoDementia »

Cheers, code was in use in another script i.e. not rewritten for this specific application.

Updated code in the original post.
dreadlyone
Posts: 48
Joined: Mon Jan 07, 2008 2:06 pm

Post by dreadlyone »

Great script. Thanks for putting this together...

In the script, on line 27,

Code: Select all

StartFolder = "X:\My Music"          '<--- Search for Folders from here down.
Can I list Multiple folders here and if so, what would be the proper format?

I have music on multiple drives. 3 to be exact.
MoDementia
Posts: 1321
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Post by MoDementia »

Sorry, you will have to run it 3 times
Kilmatead
Posts: 206
Joined: Mon Apr 07, 2008 2:16 pm
Location: Dublin

Post by Kilmatead »

Actually, seeing as it doesn't recursively reduce emptied folders, you might have to run it upwards of 9 times (3 on each collection) to be sure to get all the little buggers.

I was thinking this could be automated, but the deletion confirmation makes this more complex than necessary for such a simple task (anything denied removal would just come up again, or need to be cached so it's not queried twice or thrice), so it's easier to just re-run it.

But, how or never. Thank you again MoDementia.
callmetom
Posts: 90
Joined: Sun Jul 15, 2007 12:18 pm

Tool 'Remove Empty Directories'

Post by callmetom »

I use the free tool 'Remove Empty Directories':

You can configure there what means 'empty Directory'.
It works very well and has also optionally shell integration.

You need to execute it with 'admin rights'.

You can find it here (along with screenshots):

http://www.jonasjohn.de/lab/red.htm

System Requirements
Microsoft .NET Framework 2.0
(The installer should check if you have installed the .NET Framework 2.0 and will install it if not)

License

RED is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
My Specs:
Windows XP / SP2
Always latest MM version
Sorry for my sometimes bad english (-:
Kilmatead
Posts: 206
Joined: Mon Apr 07, 2008 2:16 pm
Location: Dublin

Post by Kilmatead »

Well that takes all the fun out of it. :D
callmetom
Posts: 90
Joined: Sun Jul 15, 2007 12:18 pm

Post by callmetom »

Kilmatead wrote:Well that takes all the fun out of it. :D
Yeah i know :-? - but thats the way it should work.

Meanwhile i use this tool :lol:

Take it as a hint for more features to come :wink:
My Specs:
Windows XP / SP2
Always latest MM version
Sorry for my sometimes bad english (-:
Kilmatead
Posts: 206
Joined: Mon Apr 07, 2008 2:16 pm
Location: Dublin

Post by Kilmatead »

callmetom wrote:Yeah i know :-? - but thats the way it should work.
The script, however, is still better suited to MM's proclivities as it preserves the .png/.jpg files (as a backup in case you really wanted the album-art) before removing the folders.

So all is not lost for the little guy reinventing the wheel! :D

RED, though, is certainly very useful "in the bigger picture." Thanks.
dreadlyone
Posts: 48
Joined: Mon Jan 07, 2008 2:06 pm

Post by dreadlyone »

Ya, I had already went through the process of running it multiple times on each drive before posting and I managed to clean up quite a bit of left over folders with just album art. Thought I would ask anyways.

I love the script :D. I am a happy camper.
SouthernGal
Posts: 16
Joined: Sat Mar 29, 2008 5:55 am

Finding Empty Folders

Post by SouthernGal »

I have been using "RED version 2.1.0.0" (free program...just google) and I'm tickled to death with it. I'm using it with Vista Ultimate in compatibility mode as administrator with no problems and 100% success. It will batch process and find empty folders and/or nearly empty folders containing only the criteria you define (such as album art)..........then you can delete them with the push of one button. Has saved me hours!
callmetom
Posts: 90
Joined: Sun Jul 15, 2007 12:18 pm

Re: Finding Empty Folders

Post by callmetom »

SouthernGal wrote:I have been using "RED version 2.1.0.0" (free program...just google) and I'm tickled to death with it. I'm using it with Vista Ultimate in compatibility mode as administrator with no problems and 100% success. It will batch process and find empty folders and/or nearly empty folders containing only the criteria you define (such as album art)..........then you can delete them with the push of one button. Has saved me hours!
I post this tool a few posts before ?
My Specs:
Windows XP / SP2
Always latest MM version
Sorry for my sometimes bad english (-:
Kilmatead
Posts: 206
Joined: Mon Apr 07, 2008 2:16 pm
Location: Dublin

Post by Kilmatead »

Maybe she's a fan of yours?

Some people like to respond to topics before reading the actual content. Rather like if the headline were "God Is Dead and The War Has Begun" - the appropriate response would "obviously" be "Anything special happening today?"

Humans on the internet are weird. :wink:
Post Reply