How to delete subfolders and files from parent folders found in the variable of a bat script?
Posted: 28 Mar 2020 20:47
What I'm trying to do is find all the folders named "temp" on local disk C and then delete all files and subfolders that are inside it, but I don't know how to delete it, I only managed to get to the part of finding all folders and put them in the variable, but I don't know the correct code to delete. Help.
Code: Select all
@echo off
setlocal
setlocal enabledelayedexpansion
@echo off
for /d /r "c:\" %%i in (temp) do (
@if exist "%%i" (
@set _variable=%%i
@echo !_variable!
)
)
endlocal