Reputation: 43
I am trying this 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%
I get error if the path %~dp0 contains spaces like "D:\my work". Although I used usebackq and back quote instead of single quote.
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?
Upvotes: 4
Views: 3261
Reputation: 4055
If this doesn't work:
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
Upvotes: 2