Answer the question
In order to leave comments, you need to log in
How to delete bulk folders weighing less than 1mb?
Please tell me, there is a folder in which there are thousands of folders.
I need to delete folders in this folder that weigh less than 1 megabyte . I saw solutions on the Internet, but there
is
only deleting files, not the whole folder (If it weighs less ...)
, with file deletion
@Echo Off
SetLocal EnableExtensions
Set Fldr=Z:\SomeFolder
For /R %Fldr% %%I In (*.*) Do If %%~zI LSS 1024 Del /F /Q "%%~I"
Answer the question
In order to leave comments, you need to log in
Let's not complicate everything with the command line or Power Shell, but let's act clearly and simply, without being afraid to make a mistake.
1. Download the free program WizTree
2. Scan the desired partition of the disk or select only the folder (F3) from the file menu. Scanning the entire disk takes 1-3 seconds. Folder scanning is even faster.
3. Click Sort by size and all folders will be sorted by size (descending / ascending)
Here's how it looks:
The main problem is to quickly find out the size of the directory. There are no standard cmd tools for this.
It remains only to do a recursive traversal of each directory and sum up the sizes of each file, as soon as the total size exceeds 1 MB, you can stop counting and skip the directory.
The size of a particular file can be obtained from the for /f loop variable using the %%~zi modifier. The same modifier applies to numbered procedure parameters.
See:
for /?
call /?
set /?
rmdir /?
If this is not a task that needs to be performed regularly, but a one-time task, then it can be done manually in just a few seconds (not counting the time that Windows spends deleting and calculating the size of folders).
Run FAR manager , open the desired folder, enable sorting by size, select all files and folders with an asterisk or plus (maybe you need to enable folder selection in the settings), press F3. This will calculate the size of all selected folders. Since sorting by size has been enabled, it remains only to hold down the ins key to correct the selection so that folders smaller than 1 MB are selected. Now delete them via F8 or Del.
I guess that a similar trick can be done through Total Commander, but I have never been a fan of it and therefore I can’t say for sure about it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question