Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.