我想将日志文件从多个位置移动到当前日期在同一位置的另一个文件夹,源路径取自文本文件。并且源路径包含导致错误发生的空格。
下面是脚本:
ECHO ON
set curr_date=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%
for /f "tokens=*" %%i in (C:\Users\kyckeams\Desktop\Batch\source.txt) do (
set "location=%%i"
call :Move
)
goto:EOF
:Move
cd %location%
cd /D %location%
mkdir %curr_date%
forfiles /p %location% /m *.log /d -2 /c "cmd /c move %location%*.* %location%%curr_date%"
PAUSE
我得到的错误是:
C:\Users\kyckeams\Desktop\Batch>ECHO ON
C:\Users\kyckeams\Desktop\Batch>set curr_date=20131102
C:\Users\kyckeams\Desktop\Batch>for /F "tokens=*" %i in (C:\Users\kyckeams\Desktop\Batch\source.txt) do (set "location=%i" call :Move)
C:\Users\kyckeams\Desktop\Batch>(set "location=D:\kycintg\KenyaSpecificServices\Unidoc_DML_Executor_Kenya\Log Files\" call :Move )
C:\Users\kyckeams\Desktop\Batch>cd D:\kycintg\KenyaSpecificServices\Unidoc_DML_Executor_Kenya\Log Files\
C:\Users\kyckeams\Desktop\Batch>cd /D D:\kycintg\KenyaSpecificServices\Unidoc_DML_Executor_Kenya\Log Files\
D:\kycintg\KenyaSpecificServices\Unidoc_DML_Executor_Kenya\Log Files>mkdir 20131102
D:\kycintg\KenyaSpecificServices\Unidoc_DML_Executor_Kenya\Log Files>forfiles /p D:\kycintg\KenyaSpecificServices\Unidoc_DML_Executor_Kenya\Log Files\ /m *.log /d -2 /c "cmd /c move D:\kycintg\KenyaSpecificServices\Unidoc_DML_Executor_Kenya \Log Files\*.* D:\kycintg\KenyaSpecificServices\Unidoc_DML_Executor_Kenya\Log Files\20131102"
ERROR: Invalid argument/option - 'Files\'. Type "FORFILES /?" for usage.
按任意键继续 。. .
需要帮助..请...