Delete empty folders (one-click function)
Moderators: Hacker, petermad, Stefan2, white
Delete empty folders (one-click function)
It would be usefull to have one-click function for deleting empty folders. User would not have to go through many steps to do that job. The function would function like that:
For each folder - if count of files=0 and folders=0 then delete else ignore (skip) - next folder. Repeat the For each folder... till no empty folder is found.
There could be option to delete or ignore folders with description.
Related post: https://www.ghisler.ch/board/viewtopic.php?t=76689
For each folder - if count of files=0 and folders=0 then delete else ignore (skip) - next folder. Repeat the For each folder... till no empty folder is found.
There could be option to delete or ignore folders with description.
Related post: https://www.ghisler.ch/board/viewtopic.php?t=76689
Re: Delete empty folders (one-click function)
Thats already easy done using an Everything search in TC like the following:
ev:D:\ folder: childcount:0
Finds all empty folders on drive D: which don't contain any file or folder.
Other options of Everything are also possible.
ev:D:\ folder: childcount:0
Finds all empty folders on drive D: which don't contain any file or folder.
Other options of Everything are also possible.
Windows 11 Home, Version 24H2 (OS Build 26100.3915)
TC 11.51 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
TC 11.51 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
Re: Delete empty folders (one-click function)
to Horst.Epp:
Is it one-click function? My request is one-click.
Do I have to write path or it is given from active window? My request is not to write but be in folder and click to delete empty folders in it.
What is result? Will all empty folders be deleted, or will it only search empty folders? You write "finds", but my request is "delete".
Do I have to repeat it if there are descript.ion files? My request is one-click, no multiply.
I want full automated process without clicking, writing, selecting, repeating etc.
I use method described here: https://www.ghisler.ch/board/viewtopic.php?t=76689
Is Everything better than my method?
Is it one-click function? My request is one-click.
Do I have to write path or it is given from active window? My request is not to write but be in folder and click to delete empty folders in it.
What is result? Will all empty folders be deleted, or will it only search empty folders? You write "finds", but my request is "delete".
Do I have to repeat it if there are descript.ion files? My request is one-click, no multiply.
I want full automated process without clicking, writing, selecting, repeating etc.
I use method described here: https://www.ghisler.ch/board/viewtopic.php?t=76689
Is Everything better than my method?
Last edited by oko on 2022-05-20, 19:37 UTC, edited 1 time in total.
Re: Delete empty folders (one-click function)
2oko
These kinds of tasks are done by scripts. You can already find a bunch of options on the web to delete empty folders.
These kinds of tasks are done by scripts. You can already find a bunch of options on the web to delete empty folders.
Overquoting is evil! π
Re: Delete empty folders (one-click function)
to Flasher
Yes, done by sripts, options on the web, external solutions and combinations... but not simple and trusted one-click function built in TC. It is TC suggestion topic, so I automatically suppose to have this function built in TC, do not consider external solutions. It is feature request for TC.
Yes, done by sripts, options on the web, external solutions and combinations... but not simple and trusted one-click function built in TC. It is TC suggestion topic, so I automatically suppose to have this function built in TC, do not consider external solutions. It is feature request for TC.
Re: Delete empty folders (one-click function)
2oko
"These kinds of" means that you can forget about the function in TC. There won't be this, 100%, as well as heaps of even less specific things. Therefore, only a script with one trusted click. )
"These kinds of" means that you can forget about the function in TC. There won't be this, 100%, as well as heaps of even less specific things. Therefore, only a script with one trusted click. )
Overquoting is evil! π
Re: Delete empty folders (one-click function)
You don't have to enter paths if you use ed: instead of ev:oko wrote: 2022-05-19, 21:10 UTC to Horst.Epp:
Is it one-click function? My request is one-click.
Do I have to write path or it is given from active window? My request is not to write but be in folder and click to delete empty folders in it.
What is result? Will all empty folders be deleted, or will it only search empty folders? You write "finds", but my request is "delete".
Do I have to repeat it if there are descript.ion files? My request is one-click, no multiply.
I want full automated process without clicking, writing, selecting, repeating etc.
I use method described here: https://www.ghisler.ch/board/viewtopic.php?t=76689
Is Everything better than my method?
as this uses the current TC source path.
Its not a one click, you have to feed the results to the list box, select all and hit delete.
I don't have the need to delete empty dirs often.
Its nothing urgent and therefore I don't need a one click action.
But if that is importand you have to script it.
Windows 11 Home, Version 24H2 (OS Build 26100.3915)
TC 11.51 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
TC 11.51 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
Re: Delete empty folders (one-click function)
2oko
I can make a button for you that automates this method - you only have to click one time to confirm that you want to delete - is that of interest?I use method described here: https://www.ghisler.ch/board/viewtopic.php?t=76689
No, it is worse - because it only finds the outermost directories - so if you have c:\xx\yy\zz and xx and yy are enpty except for the next subdir, only zz gets deleted, you would have to run the command two times more to delete yy and zz.Is Everything better than my method?
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
- Vochomurka
- Power Member
- Posts: 816
- Joined: 2005-09-14, 22:19 UTC
- Location: Russia
- Contact:
Re: Delete empty folders (one-click function)
I use Xxcopy tool for this purpose. I created batch file with one line
It's exactly one-click button 
Code: Select all
xxcopy.exe %1 /rmdir /x*.* /yy

Single user license #329241
PowerPro scripts for Total Commander
PowerPro scripts for Total Commander
Re: Delete empty folders (one-click function)
A button solution, using the dirsizecalc plugin could be:
Add this to the [Searches] section of your wincmd.ini file:
And add this to your usercmd.ini file:
And make this button:
Altenative solution using 'Everything':
Add this to the [Searches] section of your wincmd.ini file:
And add this to your usercmd.ini file:
And make this button:
The buttons will not always work properly If there are . (dots) in the folder name and the parameter SortDirExt=1 is set in wincmd.ini. SortDirExt=1 is NOT default for TC and can ONLY be set by adding it manually to wincmd.ini - so most users will not have this setting.
If you do not want to end up with sorting by Name, you can change the cm_SrcByName to the sort order you want.
If you do not want to end up with sorting folders like files you can ADD cm_SwitchDirSort 1 to the end of the command line.
The sorting commands in the multi commad line are necessary to make TC delete the folders deepest in the paths first.
Add this to the [Searches] section of your wincmd.ini file:
Code: Select all
Empty folders_SearchFor=
Empty folders_SearchIn=
Empty folders_SearchText=
Empty folders_SearchFlags=0|012002010021|||||||||0000|||
Empty folders_plugin="dirsizecalc.Contains Files" = No
Code: Select all
[em_findEmptyFolders]
cmd=LOADSEARCH ==Empty folders
Code: Select all
TOTALCMD#BAR#DATA
cm_SrcByExt 2,em_findEmptyFolders,cm_SwitchDirSort 2,cm_SrcByExt 2,cm_SelectAllFolders,cm_Delete,cm_GoToParent,cm_SrcByName
wcmicons.dll,64
Delete empty folders (DirSizecalc plugin)
-1
______________________________To make the button:
1. Mark the text in the box here above (click SELECT ALL).
2. Copy it to the ClipBoard (press Ctrl+C).
3. Right click on TC's buttonbar and choose "Paste".
Altenative solution using 'Everything':
Add this to the [Searches] section of your wincmd.ini file:
Code: Select all
Empty folders ev_SearchFor=ed: folder: size:0
Empty folders ev_SearchIn=
Empty folders ev_SearchText=
Empty folders ev_SearchFlags=0|012002010021|||||||||0000|||
Code: Select all
[em_findEmptyFoldersEV]
cmd=LOADSEARCH ==Empty folders ev
Code: Select all
TOTALCMD#BAR#DATA
cm_SrcByExt 2,em_findEmptyFoldersEV,cm_SwitchDirSort 2,cm_SrcByExt 2,cm_SelectAllFolders,cm_Delete,cm_GoToParent,cm_SrcByName
wcmicons.dll,64
Delete empty folders ('Everything')
-1
To make the button:
1. Mark the text in the box here above (click SELECT ALL).
2. Copy it to the ClipBoard (press Ctrl+C).
3. Right click on TC's buttonbar and choose "Paste".
The buttons will not always work properly If there are . (dots) in the folder name and the parameter SortDirExt=1 is set in wincmd.ini. SortDirExt=1 is NOT default for TC and can ONLY be set by adding it manually to wincmd.ini - so most users will not have this setting.
If you do not want to end up with sorting by Name, you can change the cm_SrcByName to the sort order you want.
If you do not want to end up with sorting folders like files you can ADD cm_SwitchDirSort 1 to the end of the command line.
The sorting commands in the multi commad line are necessary to make TC delete the folders deepest in the paths first.
Last edited by petermad on 2022-05-25, 00:21 UTC, edited 2 times in total.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Re: Delete empty folders (one-click function)
Code: Select all
'βββββββββββββββββββββ VBS βββββββββββββββββββββ
' Recursive deletion of empty subdirectories
' Parameter: "<folder path>" (for example, "%P")
'βββββββββββββββββββββββββββββββββββββββββββββββ
Option Explicit: Dim Dir, FSO, Col, D
Dir = "\\?\" & WSH.Arguments(0)
Const Title = " Deleting empty subfolders "
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Col = CreateObject("System.Collections.ArrayList")
If Not FSO.FolderExists(Dir) Then _
MsgBox "Set the path to the existing directory!", 262192, Title: WSH.Quit
Recursion FSO.GetFolder(Dir)
Col.Sort : Col.Reverse
For Each D in Col
Set D = FSO.GetFolder(D)
If D.SubFolders.Count = 0 And D.Files.Count = 0 Then D.Delete 1
Next
Set FSO = Nothing : Set Col = Nothing
CreateObject("WScript.Shell").Popup " Done!", 1.7, Title, 4160
Sub Recursion(oDir)
For Each D in oDir.SubFolders
If D.SubFolders.Count Then Col.Add D.Path :_
Recursion D Else If D.Files.Count = 0 Then D.Delete 1
Next
End Sub
Last edited by Fla$her on 2022-05-22, 17:16 UTC, edited 1 time in total.
Overquoting is evil! π
Re: Delete empty folders (one-click function)
Is it fun? Where are criteria?Vochomurka wrote: 2022-05-21, 16:45 UTC I use Xxcopy tool for this purpose. I created batch file with one lineIt's exactly one-click buttonCode: Select all
xxcopy.exe %1 /rmdir /x*.* /yy
![]()
Re: Delete empty folders (one-click function)
to petermad
your button solution seems interesting. I will try. I have question for now.
1. It seems to do only one deletion. Or does it repeat till no empty folders found?
2. Could it be done without dirsizecalc or any other plugin? I mean only TC without plugins would be used for all steps.
your button solution seems interesting. I will try. I have question for now.
1. It seems to do only one deletion. Or does it repeat till no empty folders found?
2. Could it be done without dirsizecalc or any other plugin? I mean only TC without plugins would be used for all steps.
Last edited by oko on 2022-05-22, 16:04 UTC, edited 1 time in total.
Re: Delete empty folders (one-click function)
to Flasher
Where has VBS code to be pasted?
Where has VBS code to be pasted?
Re: Delete empty folders (one-click function)
This searches with TC have the disadvantage that the full results for many dirs can't be checked before deletion.
Following some other thread to this topic I have found the tool RED2 very usefull.
It contains a lot of settings to make a smoth and safe deletion.
It also allows to exclude path and file names.
I use the current beta.
https://www.jonasjohn.de/red.htm
Following some other thread to this topic I have found the tool RED2 very usefull.
It contains a lot of settings to make a smoth and safe deletion.
It also allows to exclude path and file names.
I use the current beta.
https://www.jonasjohn.de/red.htm
Windows 11 Home, Version 24H2 (OS Build 26100.3915)
TC 11.51 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
TC 11.51 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64