我的 bath 文件如何处理路径示例中的空间:
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
答案1
CMD 不喜欢目录中的空格,因此请使用引号括住您的路径,如下所示:
“C:\Documents and Settings\K\Desktop\New Folder”
答案2
我在几个文件路径位置周围添加了引号……这应该有效:
@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 "tokens=*" %%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