Batch Script to delete files based on findstr regex

孤街醉人 提交于 2019-12-05 20:30:58
FOR /f "tokens=*" %%a in ('dir /b ^| findstr MY_REGEX_HERE') DO ECHO %%a 

Escape the | using a ^ before it.

Gary Walker

The CMD processor is just too limited to do what you want here, pipe is not legal in this context. You could kludge it with replacing your ECHO stub with a CALL to another batch file, but even then you will still have problems. See Want to batch move all files from directories into the parent directory and delete the subdirectory for my quick comparion of scripting environments options.

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