在批处理脚本中搜索文件并处理这些文件? [英] Search for files in a batch script and process those files?

查看:149
本文介绍了在批处理脚本中搜索文件并处理这些文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Visual Studio项目的预构建阶段中做一些事情.具体来说,我试图在项目中的所有* .resx文件上执行一些命令.这是我的东西,但是当文件/目录路径中有空格时,它不起作用.我该如何避开这些空间?

I'm trying to do some things during the pre-build phase of a visual studio project. Specifically, I'm trying to execute some commands on all *.resx files within the project. Here is what I have but it doesn't work when the files/directory path have a space in them. How do I get around these spaces?

for /f %%a in ('dir /B /S *.resx') do echo "%%a"

推荐答案

您知道for也可以在目录上递归运行吗?

You know that for can also run recursively over directories?

for /r %%x in (*.resx) do echo "%%x"

比摆弄定界符容易得多,并且可以避免运行dir.

Much easier than fiddling with delimiters and saves you from running dir.

这篇关于在批处理脚本中搜索文件并处理这些文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆