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
.
Posted Nov 9, 2017, 5:48 AM UTC
Are you taking about deleting files but keeping sub folder structure?
Warning: Recursive!
for /r %F in (*) do (del /f /q "%F")Open a Command Prompt,
cdto the top-most parent folder you wish to delete files from, copy and paste and run the command above.Explaination:
forloops through files;/rmeans go into subfolder;%Fis where file names will be stored at;in (*)filters files matching only “anything” in the file name, so every single file;doruns a command on every file found;del /f /qmeans delete without asking for confirmation every time. Sincedeldoes not work on folders, your folders are safe. In fact,forwon’t even loop folders with this syntax I believe.Thank you!