If you wish to copy all the files in a directory and its' sub-directories to different directory, without preserving
the directory structure:
CopyFlat From To
where From is the full path to the source directory and To is the full path to the target directory.
CopyFlat.bat contains:
@echo off setlocal If \{%1\} EQU \{\} goto Syntax If \{%2\} EQU \{\} goto Syntax set from=%1 set to=%2 set from=%from:"=%# set to=%to:"=%# set from=%from:\#=% set to=%to:\#=% set from=%from:#=% set to=%to:#=% if not exist "%from%" goto Syntax if not exist "%to%" goto Syntax pushd "%to%" for /f "Tokens=*" %%i in ('dir /b /s /a-d "%from%\*.*"') do call :cpy "%%i" popd endlocal goto :EOF :Syntax @echo Syntax: CopyFlat From To endlocal goto :EOF :cpy copy %1 "%~nx1"
0 comments
Hide comments