Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Below is my forfiles one-liner:

FORFILES /P "X:\LOGS\HS" /S /M *.log  /D -1 /C "CMD /C del /Q @FILE"qq ~q

Although I have the /S option to delete log files in X:\LOGS\HS, there are several subdirectories and it is not deleting log files further down the tree. How can I resolve this?

share|improve this question

I would put it down to spaces in the file/path name

when

FORFILES /P "X:\LOGS\HS" /S /M *.log  /D -1 /C "CMD /C del /Q @FILE"qq ~q

encounters X:\LOGS\HS\My Folder\Stuff.log, it will pass it to the del command as

del X:\LOGS\HS\My Folder\Stuff.log

where del will then try to remove the files X:\LOGS\HS\My and Folder\Stuff.log

To overcome this, you have to give the system some quotes to wrap the file name in.

FORFILES /P "X:\LOGS\HS" /S /M *.log  /D -1 /C "CMD /C del /Q ""@FILE"""qq ~q

should give you a little more success

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .