我最近使用for语句从命令行做了很多批处理工作。今天我决定将我正在使用的命令的一些大线捆绑到一个批处理文件中。主要问题是变量替换在某些情况下给我带来了奇怪的错误。所以有人可以解释一下,这是如何运作的:
:: Split
for /F "tokens=*" %%F in ('dir /s /b *.cue') do (
pushd .
cd %%~dpF
mkdir out
cd out
echo "%%~dpF*.flac"
popd
)
和此:
:: Split
for /F "tokens=*" %%F in ('dir /s /b *.cue') do (
pushd .
cd %%~dpF
mkdir out
cd out
shntool.exe split -f "%%F" -t %t -m /-?; -o flac "%%~dpF*.flac"
popd
)
给了我这个错误:
The following usage of the path operator in batch-parameter
substitution is invalid: %~dpF*.flac"
答案 0 :(得分:1)
我建议
shntool.exe split -f "%%F" -t %t -m /-?; -o flac "%%~dpF*.flac"
被解释为
shntool.exe split -f "%%F" -t %~dpF*.flac"
将%t -m /-?; -o flac "%
视为环境变量。
使用
shntool.exe split -f "%%F" -t %%t -m /-?; -o flac "%%~dpF*.flac"