Search code examples
batch-filefile-ioforfiles

Getting forfiles help page where it shouldn't


I'm using the following command to delete files older than X days (%numb% is the amount of days):

forfiles -p "%temp%" -s -m *.* -d %numb% -c "cmd /c del @path"

Still, when I execute it it just prompts me with all features of forfiles and how it should be used.


Solution

  • You may want to change your "DEL @path" to "echo @path" until you get the kinks worked out...

    On my XPsp3 machine, I noticed that a hyphen before the number of days (%numb%) was important. So, this:

    forfiles -p "%temp%" -s -m *.* -d 30 -c "cmd /c echo @path"
    

    yeilded this: ERROR: No files found with the specified search criteria.

    but this:

    forfiles -p "%temp%" -s -m *.* -d -30 -c "cmd /c echo @path"
    

    gave me a directory listing