There is this directory structure:
Dir1
--Dir2
--File1
--File2
--Dir3
--File3
--File4
--File5
Now I want to copy all the files in subdirectory (Dir2, Dir3) to parent Directory Dir1 using batch files. I have come up with the below code but it doesn't work perfectly. I get the below output -
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)?
Code -
@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