Solved Need Batch to delete folders that are a certain size

November 29, 2016 at 12:05:15
Specs: Windows 10, 16gb
Looking for a Batch (not vbs) file to delete folders that are 500k and under. I did do a search here but only found a vbs post and I have no clue how to use vbs.

message edited by Gshark


See More: Need Batch to delete folders that are a certain size

Report •

#1
November 29, 2016 at 21:07:43
✔ Best Answer
:: this generates the DEL commands but DOES NOT execute them:
for /d %%z in (*.*) do @for /f "tokens=3" %%a in ('dir /-c %%z^| @find "File(s)"') do @if %%a leq 500000 @echo rd /s /q %%~pnxz
::-------- end snip #1

:: this just generates a list of all directories and their component-files total size:
for /d %%z in (*.*) do @for /f "tokens=3" %%a in ('dir /-c %%z^| find "File(s)"') do @echo %%~pnz %%a
::-------- end snip #2

(RUN/execute from the base directory of subs you are targeting for deletion).
Note that no allowance is made for subdirectories beneath the targeted level!

message edited by nbrane


Report •

#2
November 29, 2016 at 21:50:38
Ill try that.thanks Nbrane :)

Report •
Related Solutions


Ask Question