在一个批处理文件的循环空间路径 [英] Path with spaces in for loop of a batch file

查看:146
本文介绍了在一个批处理文件的循环空间路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这个命令:

for /f "tokens=3 usebackq" %%i in (`"%~dp0imagex.exe" /info "%~dp0DVD\sources\install.wim" ^| findstr /c:"Image Count:"`) do set ImageCount=%%i 
echo %ImageCount%

我得到的错误,如果路径%〜DP0包含空格一样的D:\\我的工作。虽然我用有usebackq和背部,而不是报价单引号的。

I get error if the path %~dp0 contains spaces like "D:\my work". Although I used usebackq and back quote instead of single quote.

该错误信息是:D:\\我的'。不被识别为内部或外部命令,可操作的程序或批处理文件

the error message is:'D:\my' is not recognized as internal or external command, operable program or batch file.

什么是错误的,我的命令?

What is the wrong in my command?

推荐答案

如果这不起作用:

for /f "tokens=3 usebackq" %%i in (`"%~dp0imagex.exe" /info "%~dp0DVD\sources\install.wim" ^| findstr /c:"Image Count:"`) do set ImageCount=%%i 
echo %ImageCount%


试试这个:


Try this:

pushd %~dp0
for /f "tokens=3 usebackq" %%i in (`imagex.exe" /info "DVD\sources\install.wim" ^| findstr /c:"Image Count:"`) do set ImageCount=%%i 
echo %ImageCount%
popd

这篇关于在一个批处理文件的循环空间路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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