Open Notepad or any text editor on your Windows computer.
Type the following command in the text editor:
Open Notepad or any text editor on your Windows computer.
Type the following command in the text editor:
forfiles /p "C:\path\to\folder" /s /m *.* /d -7 /c "cmd /c del @path"
Replace "C:\path\to\folder" with the actual path to the folder that contains the files you want to delete.
Replace "-7" with the number of days you want to use as the cutoff age for deleting files. In this example, "-7" means that any file older than 7 days will be deleted.
Save the file with a .bat extension, such as "delete_old_files.bat".
Double-click the .bat file to run the script. It will automatically delete any files in the specified folder that are older than the number of days you specified.