2013-03-19 111 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