Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
caiopacheco02
- Posts: 1
- Joined: 28 Mar 2020 20:44
#1
Post
by caiopacheco02 » 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
Last edited by
Squashman on 29 Mar 2020 13:41, edited 1 time in total.
Reason: MOD EDIT: Please use code tags?
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#2
Post
by Squashman » 29 Mar 2020 13:46
Open up a command prompt and type: help. I bet you will find a command or two that will help you. Probably easier to Google search for deleting a file or folder using a batch file.
You do not need to assign the FOR variable to an environmental variable, which also means you will not need delayed expansion.