有这个目录结构:
Dir1
--Dir2
--File1
--File2
--Dir3
--File3
--File4
--File5
现在我想使用批处理文件将子目录(Dir2,Dir3)中的所有文件复制到父目录 Dir1。我想出了下面的代码,但它不能完美地工作。我得到以下输出 -
Directory2 --It has 4 files all together
Invalid number of parameters
Invalid number of parameters
Does E:\Directory1\Copy\File1.dat specify a file name -- And only this file gets copied
or directory name on the target
(F = file, D = directory)?
代码 -
@echo off
call :treeProcess
Pause
goto :eof
:treeProcess
rem Do whatever you want here over the files of this subdir, for example:
for /D %%d in (*) do (
echo %%d
cd %%d
for %%f in (*) do xcopy %%f E:\Movies\Copy\%%f
call :treeProcess
cd ..
)
exit /b