Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 为批处理文件添加空间_Batch File - Fatal编程技术网

Batch file 为批处理文件添加空间

Batch file 为批处理文件添加空间,batch-file,Batch File,我的批处理如何处理路径中的空间示例: C:\Documents and Settings\K\Desktop\New文件夹 @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 >&

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


C:\Documents and Settings\K\Desktop\New文件夹

@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

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

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")
您应该使用比
%%z
更好的
%%z
~
会删除额外的双引号


根据Peter Wright的答案编辑。

是通过
%1
的路径还是作为
%CD%
的路径?注意:将
“%1”
更改为
“%~1”
.C:\Documents and Settings\K\Desktop\DECODER>(复制“C:\Documents”“bin\file.php”和“php.exe”“bin\DECODER.php”“bin\file.php”&&move“bin\file.php”“C:\Documents”和&del“bin\file.php”)1个文件
bin\file.php:error找不到C:\Documents and Settings\K\Desktop\DECODE R\bin\file.php
for /F "USEBACKQ delims=" %%e in .....