When you need to process multiple files in a batch file use forfiles.exe
For example, to recursively delete all files in the directory U:\Downloads older than 7 days:
- Open Notepad
- Type the following:
forfiles.exe /p "U:\Downloads" /m *.* /s /D -7 /c "cmd /c del @path /q"
/p [path]= path
/m = File select mask. In this case *.* i.e. all files.
/s = recursive
/D [date/+dd/-dd]= select files with last modified date. In this case less than or equal to current date minus 7 days.
/c [command]= command to run for each file surrounded by quotes. Switches can be used in the command string (See more information).
- Save the file as deletedownloads.bat (change file type to all files)
- Run it by double clicking on it.
Post a Comment