• 0

Forfiles Error

  • 0

Hi All,
I have a script that deletes files in folder that are older than 1 year.

FORFILES /P D:Doc\ /M *.txt /D -366 /C “cmd /c del @path”

It works good, except when it does not find any files older than 1 year, it gives the following error:

ERROR: No files found with the specified search criteria.

is there any way i could ask to ignore this error



1 Answer

  1. you might try this:
    FORFILES /P D:Doc\ /M *.txt /D -366 /C “cmd /c del @path” 2>nul
    or you might need it like this:
    FORFILES /P D:Doc\ /M *.txt /D -366 /C “cmd /c del @path 2>nul”

    • 0