Forfiles - spaces in folder path

岁酱吖の 提交于 2019-12-06 13:43:56

Enclose the path in quotes:

FORFILES -p "%spinputarchrootpath%" -m *.csv -d -365 -c "CMD /C DEL @FILE"

Note, there's a space between -p and "%spinputarchrootpath%". Without a space in this case it won't work.

I'd the same problem and found the solution. I think your folder-variable of the folder you wish to empty has a backslash at the end.

This will NOT work:

echo J|forfiles /P "C:\temp files\" /S /M * /D -7 /C "cmd /c del /F /S /Q @path"

... but this works (without backslash)

echo J|forfiles /P "C:\temp files" /S /M * /D -7 /C "cmd /c del /F /S /Q @path"

Regards

Tino

As a work around first change directories to the folder you want, and then execute forfiles without the /p parameter.

CD %spinputarchrootpath%
FORFILES -m*.csv -d-365 -c"CMD /C DEL @FILE"
ErtjeTheFreeze

Check post: How to Tell FORFILES to Execute Command on Path?

The problem lies in the part: -c"CMD /C DEL @FILE"

Use: -c"CMD /C DEL ^0x22@FILE^0x22" to put extra double quotes around the file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!