Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

windows command line delete a file in all subdirectories

:: to delete the file named 'foo.txt' from all subdirectories of the current 
:: working directory
:: run this command in the windows cmd.exe shell:
for /f %f in ('dir /d /b') do del /s /q %ffoo.txt

:: if 'foo' is a directory, the previous command merely empties the directory
:: to clean up and remove the empty foo directories afterwards run this command
for /f %f in ('dir /d /b') do rd /s /q %ffoo
 
PREVIOUS NEXT
Tagged: #windows #command #line #delete #file #subdirectories
ADD COMMENT
Topic
Name
6+1 =