r/windows•
rdx8

Is there any way to delete items inside a bunch of folders automatically without deleting the folders themselves?

.

Posted Nov 9, 2017, 5:48 AM UTC

43
Vassile-D•

Warning: Recursive!

for /r %F in (*) do (del /f /q "%F")

Open a Command Prompt, cd to the top-most parent folder you wish to delete files from, copy and paste and run the command above.

Explaination: for loops through files; /r means go into subfolder; %F is where file names will be stored at; in (*) filters files matching only “anything” in the file name, so every single file; do runs a command on every file found; del /f /q means delete without asking for confirmation every time. Since del does not work on folders, your folders are safe. In fact, for won’t even loop folders with this syntax I believe.

3
rdx8OP•

Thank you!

1
danskeman•

Are you taking about deleting files but keeping sub folder structure?

2