0

我的批处理如何处理路径示例中的空间:

C:\Documents and Settings\K\Desktop\新建文件夹

@echo off
pushd "%~dp0"
IF EXIST "%1" GOTO DECODE_INDIVIDUAL

:DECODE_MULTIPLE
xcopy /s /c /d /e /h /i /r /y "%cd%\encoded" "%cd%\decoded\"
dir "%cd%\decoded\*.php"  /A:-D /B /O:N /S >> "%cd%\filelist.txt"

@echo on
for /F %%e in ("%cd%\filelist.txt") do ( copy "%%e" "bin\file.php" && "php.exe" "bin\decoder.php" "bin\file.php" && move "bin\file.php" "%%e" && del "bin\file.php")
del /Q "%cd%\filelist.txt"
GOTO DECODE_END

:DECODE_INDIVIDUAL
@echo on
"php.exe" "%cd%\bin\decoder.php" "%1"

:DECODE_END
4

2 回答 2

1
for /F "USEBACKQ delims=" %%e in .....
于 2013-03-19T22:50:18.990 回答
0

如果路径或文件名中有空格,则必须将分隔符设置为空:

for /F "usebackqdelims=" %%e in ("%cd%\filelist.txt") do ( copy "%%~e" "bin\file.php" && "php.exe" "bin\decoder.php" "bin\file.php" && move "bin\file.php" "%%~e" && del "bin\file.php")

您应该使用 better %%~zthan %%z~确实会删除额外的双引号。

根据彼得赖特的回答编辑。

于 2013-03-19T20:49:53.507 回答