Package - delete folders

First of all: I am completely new to the party.

I want to write a batch file that deletes files and folders that are minimal. 5 days or older. This code works fine with all files:

FORFILES /p "C:\Users\rs\Desktop\testbatch" /s /m *.* /d -5 /c "cmd /c if not @isdir==TRUE del @path" 

But my folders are still here, and I can’t delete them if they are min. 5 days. Can someone please give me a hint?

Greetings

+6
source share
2 answers

del deletes files while you need to use rmdir for directories.

+2
source
 FORFILES /p "C:\Users\rs\Desktop\testbatch" /s /m *.* /d -5 /c "cmd /c if @isdir==TRUE rd /s /q @path " 
+1
source

Source: https://habr.com/ru/post/956530/


All Articles