Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    deleting empty folders (XP PRO (SP2))

    Hello, does anyone know of a utility that can easily find empty folders and delete them? Or is it possible to use Windows Search to search for empty folders?

    Thanks,

    Chris (Hunt)

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: deleting empty folders (XP PRO (SP2))

    I don't know if this will do it for you, but the first thing that comes to mind is TreeSize. Not exactly automatic but it will show you where your space usage lies.
    -Mark

  3. #3
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: deleting empty folders (XP PRO (SP2))

    Thanks Mark,

    Something that automatically deleted empty folders would be best but this program is much, much better than nothing. It shows me where to look and I can delete the folders by hand. It integrates into Windows Explorer quite nicely.

    Best wishes,

    Chris

  4. #4
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: deleting empty folders (XP PRO (SP2))

    Chris

    I would question why you would want to do this, except for tidiness' sake, because the amount of disk space that will get returned is very probably zero!

    That said, it is very straightforward to do, <big>but</big> you must <big>test</big> this on a spare hard disk, or a diskette, or a USB PenDrive/flash memory disk before doing it on your hard disk! This uses the Command Prompt Window.

    On this "throwaway disk" (I'm calling it D: here, your drive letter may vary) create some directory trees, some with files in, some without. Do a directory list of these structures, preferably to a file on your hard disk e.g. DIR D: /s > C-Before.TXT

    Move to the root of this drive by typing D: and press return/Enter, and make VERY SURE that the prompt says D: and NOT, repeat NOT, C:AnythingAtAll

    In the Command Prompt Window type for /r %x in (.) do echo %x
    which will enumerate all the directories you will be testing for emptiness

    When you're satisfied with the list, now enter for /r %x in (.) do rd %x
    Do NOT under any circumstances use the /S switch in the RD command!!!

    This should have deleted ONLY those directories regarded as empty, those containing no files AND no sub-directories. There will be messages about not being able to remove directories because they weren't empty. Do another directory list, using DIR D: /s > C-after.TXT

    Now very carefully compare the two lists, to ensure that the Remove Directory command has removed ONLY those directories which you expected/wanted to be removed.

    If this is the case, then we can now do a complete backup of everything on your C: drive (ha-ha, probably!).

    Now move to the root directory of the C: drive by typing CD /D C: and pressing return/Enter. The prompt must read C:

    Type the command you used before, namely for /r %x in (.) do rd %x

    This should remove any empty directories.

    YOU MUST TEST THE PROCEDURE ON A TEST DRIVE BEFORE TRYING IT ON YOUR HARD DISK

    John

    PS I've tested it on an A: diskette and the only wrinkle is that you may have to run the FOR / RD command line more than once, because if you have a directory tree where the directories are all empty, the command will only remove the lowest subdirectory each time, because that it the only one which is empty at the time the command is running!

    PPS Is removing empty subdirectories <big>really</big> that important?
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  5. #5
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: deleting empty folders (XP PRO (SP2))

    Glad to hear that you like it...hope it does what you need!
    -Mark

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: deleting empty folders (XP PRO (SP2))

    > the amount of disk space that will get returned is very probably zero!

    I think it would be the equivalent of deleting the same number of 1 byte files. That is, the benefit would depend on the minimum cluster size.

  7. #7
    Uranium Lounger viking33's Avatar
    Join Date
    Jun 2002
    Location
    Cape Cod, Massachusetts, USA
    Posts
    6,308
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: deleting empty folders (XP PRO (SP2))

    Chris,
    System Mechanic will search for and optionally delete zero length folders. Just go to the "Clean" screen and open options to select zero length search. You can also set it for temp files and other things. It's a GOOD utility and I rely on it heavily.

    You can download a 30 trial at SYSTEM MECHANIC
    BOB
    http://lounge.windowssecrets.com/S/flags/USA.gif http://lounge.windowssecrets.com/S/f...sachusetts.gif


    Long ago, there was a time when men cursed and beat on the ground with sticks. It was called witchcraft.
    Today it is called golf!

  8. #8
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: deleting empty folders (XP PRO (SP2))

    Thanks for the replies.

    John, I may try your procedure but it sounds very scary!

    Bob, I'm trying the trial version of System Mechanic. It looks very useful for lots of tasks but I can't get it to find empty folders. I selected the option you described and I tested it on one drive. It found several 0 byte files but not an empty file folder. I tried adding the extension "(NONE)" as a new type to search for but it didn't work. Am I missing something?

    I allowed a large number of duplicate files to accumulate on various drives over the years. I've been using

    Clone Spy (v1.51) to find duplicates. Quite often I have lots of empty folders left. Finding them and removing them manually is a drag. It's much easier with "TreeSize" but removal still needs to be done manually.

    Chris

  9. #9
    Uranium Lounger viking33's Avatar
    Join Date
    Jun 2002
    Location
    Cape Cod, Massachusetts, USA
    Posts
    6,308
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: deleting empty folders (XP PRO (SP2))

    Chris,
    You are right, it's only for zero length files not folders.
    But........try this one. I KNOW it checks for empty folders also.

    TweakXP Pro It's a free trial download also.


    Look under Utilities>Clean Unnecessary files>Empty folders
    BOB
    http://lounge.windowssecrets.com/S/flags/USA.gif http://lounge.windowssecrets.com/S/f...sachusetts.gif


    Long ago, there was a time when men cursed and beat on the ground with sticks. It was called witchcraft.
    Today it is called golf!

  10. #10
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: deleting empty folders (XP PRO (SP2))

    Hello John,

    I'm thinking of trying your method. I wonder what you think of the procedure here:

    http://www.pcmag.com/article2/0,1759,805015,00.asp

    It saves a list of folders to a batch file in reverse order. Because they are in reverse order it is only necessary to remove directories once.

    Actually, I tried this but it didn't work. I tried RM and RMDIR in the batch file but no empty folder was removed. But when I tried removing one folder as a test from the command line it did work (using rmdir). I don't understand why the batch file failed.

    Removing Empty folders isn't something I want to do every day so I'd rather avoid paying for a utility unless it has a lot of other useful features.

    Thanks,

    Chris

  11. #11
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: deleting empty folders (XP PRO (SP2))

    <hr>...I tried RM and RMDIR in the batch file... <hr>
    Just an observation, Chris, in case you're keeping on. RM should be RD. Might that be why it didn't work?

  12. #12
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: deleting empty folders (XP PRO (SP2))

    Chris

    Their method is a variant of mine. To make my version a one-pass method, try <pre>for /f %x in ('dir /ad /b /s ^| sort /r') do rd %x</pre>

    If you put it into a BATch file (called, say, DELMTDIR.BAT) change each single percent sign to a pair of percent signs.

    As before, it would be a Very Good Idea to TEST IT on a diskette, say. Ignore the "The directory is not empty" message for each directory which is not empty (surprise!).

    John

    PS Al is correct that RM should be RD - presume a typo?

    PPS My line above assumes that you are in the ROOT (e.g. C of the drive whose empty directories you are wishing to delete.
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  13. #13
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: deleting empty folders (XP PRO (SP2))

    Thanks John,

    Yes RM was a typo (but thanks for pointing it out, Al). I tried the new command from the command line and from inside a batch file but I couldn't get it to remove anything. I have a drive that I am testing at the moment. I created some empty folders but they are still there. I'm wondering if I have mistyped some spaces. Is there a space between each element of the new command. For example, if a space were a carriage return would it look like:

    for
    /f
    %%x
    in
    ('dir
    /ad
    /b
    /s
    ^|
    sort
    /r')
    do
    rd
    %x

    I put the batch file at the root of the drive in question. I wonder what I am doing wrong.

    Chris

  14. #14
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: deleting empty folders (XP PRO (SP2))

    Chris

    The most easy way is to do NOTEPAD DELMTDIR.BAT
    then cut and paste the line from the Lounge into the NOTEPAD window.

    Then edit to your heart's content!

    The only error I can see with what you show is that the final "word" should have TWO percentage signs before the x...

    John
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  15. #15
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: deleting empty folders (XP PRO (SP2))

    Thanks John,

    That was another typo! Actually, I started by cutting and pasting the line from your lounge reply and adding two % but the bat file didn't do anything. That's why I asked. Do you have any other suggestions as to why it didn't work?

    Best wishes,

    Chris

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •