2013-03-19 118 views
0

如何我的批处理可以处理路径例如空间:附加空间批处理文件

C:\ Documents和Settings \ķ\桌面\新建文件夹

@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 
+0

路径是通过'%1'还是'%CD%'?注意:将你的'“%1”'改为'“%〜1”'。 – 2013-03-19 20:38:23

回答

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") 

你应该使用%%~z%%z好,~的确取消了额外的双人现状工商业污水附加费。

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

+0

C:\ Documents and Settings \ K \ Desktop \ DECODER>(复制“C:\ Documents”“bin \ file.php” &&“php.exe”“bin \ decoder.php”“bin \ file.php” && move“bin \ file.ph p”“C:\ Documents”&& del“bin \ file.php”) 复制1个文件。
bin \ file.php:errorCould找不到C:\ Documents and Settings \ K \ Desktop \ DECODE R \ bin \ file.php – user699998 2013-03-19 21:46:46

+0

我对我的代码做了编辑。 – Endoro 2013-03-20 05:34:04

1
for /F "USEBACKQ delims=" %%e in ..... 
+0

+1,无评论:) – Endoro 2013-03-20 08:47:29