0

I need help to modify the batch script to count the number of folders to delete. I use the code to remove those folders with yyyy-mm-dd named. And I found a similar script in the forum and try to modify it but not work.

@echo off
pushd %windir%\ABC\Log
set "folder=*-*-*"

for /f "delims=" %%i in ('dir /b /ad /o-d "%folder%"') do set "todel=%%i"
for /f %%a in ('dir /b /ad "%folder%" ^| find /c /v ""') do set "count=%%a"

For /D %%F in ("%windir%\ABC\Log\*-*-*") do rd /s /q "%%F"
pause
popd

folder

1 Answer 1

0

Use Powershell. Try the following:

Get-ChildItem -Directory '*-*-*' | Measure-Object | Select-Object Count

It will return the number of folders that comply with your filter (*-*-*).

1
  • Hi iTwasnTme, The batch does not remove those folders. It only echoes the rmdir... commandline as your image ?
    – VB88
    Apr 21, 2022 at 15:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .