Delete Empty Directories (Folders)

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
sportsnt
Junior Member
Junior Member
Posts: 2
Joined: 2004-02-12, 19:18 UTC

Delete Empty Directories (Folders)

Post by *sportsnt »

After a recent sync on a 160 GB drive, I am left with MANY empty folders. Is there a way to have TC6 search for and delete empty folders?

Thanks
User avatar
Clo
Moderator
Moderator
Posts: 5731
Joined: 2003-12-02, 19:01 UTC
Location: Bordeaux, France
Contact:

A trick...

Post by *Clo »

:)   Hello!

• Just a trick:
• Press Alt+Shift+Enter Then, all empty dirs. will remain with the indication <DIR>, while others will have their contents sizes displayed.

• I tested a search with "size=0 byte", unfortunately, that doesn't work.
So, you'll have to delete these empty (marked <DIR>) dirs. by hand.

:?:  Maybe someone else should have a better idea?

• An option to delete all empty dirs / files is ticklish to plan, because some empty dirs are useful, i.e. Temp-dirs...

:mrgreen:  Kind regards,
Claude
Clo
Last edited by Clo on 2004-02-12, 20:05 UTC, edited 1 time in total.
#31505 Traducteur Français de TC French translator Aide en Français Tutoriels Français English Tutorials
sportsnt
Junior Member
Junior Member
Posts: 2
Joined: 2004-02-12, 19:18 UTC

Post by *sportsnt »

Thanks Claude...

In my case, this is a storage drive with no system files or installed apps so if I can figure it out, I can just delete them all without concern.

Thanks again.
User avatar
Clo
Moderator
Moderator
Posts: 5731
Joined: 2003-12-02, 19:01 UTC
Location: Bordeaux, France
Contact:

Option with warning

Post by *Clo »

2sportsnt
• Ah! In that case, no problem to delete all empty dirs.

• It's an option to add in the Author's wish-list (might come with a strong warning!)
• Hoping that C. Ghisler'll have a look here :wink:

:mrgreen: KR
Claude
Clo
#31505 Traducteur Français de TC French translator Aide en Français Tutoriels Français English Tutorials
User avatar
Clo
Moderator
Moderator
Posts: 5731
Joined: 2003-12-02, 19:01 UTC
Location: Bordeaux, France
Contact:

Better trick

Post by *Clo »

2sportsnt
:D Hi again!

• Thinking to your problem still, I found an improved trick:
¤ Go to: Menu Configuration >> Options >> Display >> "Sorting directories"
¤ Tick the radio-box : "Like files (also by time)"
¤ Then, choose the sorting in the file-window " By size" (increasing order, arrow to up)
¤ Press Alt+Shift+Enter : all empty dirs. are grouped at the top of the list as <DIR>.
:oops: Please, don't try to delete the ".." virtual output dir. !
• Note 1 : there is no matter if a dir. contains an empty file; it's "saw" as empty in anyway.
• Note 2 : In my opinion, you might reset the usual dirs sorting (Always by name) when this operation is ended, since it's more handy to get dirs sorted by names…
• Besides, an option should be very opportune to get this directly !
:mrgreen: Kind regards,
Claude
Clo
#31505 Traducteur Français de TC French translator Aide en Français Tutoriels Français English Tutorials
User avatar
Clo
Moderator
Moderator
Posts: 5731
Joined: 2003-12-02, 19:01 UTC
Location: Bordeaux, France
Contact:

News from the Author---

Post by *Clo »

2sportsnt
:D   Hello !
• I just received an answer from the Author, about to find empty dirs. He confirmed that isn't possible currently.
• It seems that poses the following problem, to get that function available in any case, example :
- Whether we have a tree-part like: C:\Dir1\Sub-dir2\Sub-sub-dir3 in which Sub-sub-dir3 is empty. When we find then delete it, Sub-dir2 that contained it becomes empty itself ! To find it as empty, a second search is needed… The same when finding / deleting that Sub-dir2, so the Dir1 becomes empty too, and needs a third scanning to be found as empty…
• In fact, this whole tree-part contains none file, but it's impossible to find directly Dir1 as empty, since it contains sub-dirs.

• As a stopgap, we could ask for find only the dirs near the drive-root, having none sub-dir. inside… :?:
• If you think that could be suitable - waiting a better feature -, please let me know. A French user has the same problem, so I'ld ask for this simplest improvement as a single request.
Glad to hear your opinion,
:mrgreen:  Kind regards,
Claude
Clo
#31505 Traducteur Français de TC French translator Aide en Français Tutoriels Français English Tutorials
IGL
Member
Member
Posts: 179
Joined: 2004-02-26, 10:47 UTC
Location: Poland

Post by *IGL »

Hello,
I think I have found a good solution for that.

I've tested it under TotalCmd 6.01 but should work on earlier versions too.
It is a bit complicated, but the procedure is as follows:

1.
- Go to Configuration/Options/ Layout
select "Show status bar".
- Go to Configuration/Options/ Layout - Display
in sorting directories choose "Like Files".

You can go back to setting "Always by name" later.

2. Go to the directory which you want to purge from empty subdirs.

3. run "Find files" (Alt+F7) and search for "*.*" but in tab Advanced select: Attributes: Directory. It will result in finding all dirs and perform "Start search"

4. After searching choose "Feed to listbox". Now you have a list of all directories, subdirs, subsubdirs etc. We need to find only those that are 0 length.

5. Press Alt+Shift+Enter, after a short (or long) moment TC will count sizes of all the dirs.
6. Now in menu Show choose sorting by Size (Ctrl+F6)
7. Make sure that sorting is in Reverse Order (Bigger files/dirs first). This can be checked in menu Show / Reversed Order
8. If you move cursor through files (I recommend using keyboard - up/down arrow or PageUp/Down) you will see in a status bar the size of directory. Keep moving down until you find first dir with size 0 (zero).
9. Mark all directories below (using Insert or click and then scroll down and click last dir with Shift key pressed to mark multiply dirs)
10.You coul delete them all now, >but there is a trick - If those dirs contain empty files (size 0) then they will be deleted too :shock:.

To avoid this You can MOVE all that dirs to directroy eg. TO_DEL, then search for files only (run "Find files" (Alt+F7) and search for "*.*" but in tab Advanced DESELECT: Attributes: Directory. It will result in finding all empty files. Check those file and copy them if you need them.
You can test directory TO_DEL (where you moved those dirs previously) to make sure it is really empty (press space to mark and count size of dir). Afterwards delete directory TO_DEL.

Now you are free of all empty dirs.
It works even if you have empty subdirs in an empty dir.

//BTW: it is my first entry on TC forum. I'm glad to join you guys :D
Last edited by IGL on 2004-02-27, 12:37 UTC, edited 1 time in total.
:-)
User avatar
pdavit
Power Member
Power Member
Posts: 1529
Joined: 2003-02-05, 21:41 UTC
Location: Kavala -> Greece -> Europe -> Earth -> Solar System -> Milky Way -> Space
Contact:

Post by *pdavit »

2 IGL

>BTW: it is my first entry on TC forum.

And it looks as if we can use your brains! ;) :)

Now, I don't know if you are familiar with this: http://www.ghisler.ch/board/viewtopic.php?t=2499

but you might be able to automate your suggestion in this way. I don't know if it can be fully automated but in the worst case scenario you can at least get rid of many steps and simplify in this way the whole process.


>I'm glad to join you guys

We are glad to have you with us.
"My only reason for still using M$ Window$ as an OS is the existence of Total Commander!"
Christian Ghisler Rules!!!
Post Reply