I'm copying a lot of folders/subdirectories from one network drive to another, however, the names of these files aren't known and I only want to copy the contents of the folders that have a name match.
Ex: srcdir has folders f1, f3, f4, f9 and destdir has folders f3, f5, and f9: since the names of folders f3 and f9 match, the contents (files and subdirectories) of f3 & f9 found in srcdir will be copied into their respective folders in destdir.
I've tried using xcopy but it only copies the files, and I've also tried
robocopy C:\test1 C:\test2 /u /s
but that skips over everything.
How would I go about copying the contents of a folder from the source network drive into its matching folder in the destination drive? Here's the code I have so far:
@ECHO OFF
setlocal EnableDelayedExpansion
for /d %%i in ("C:\test1\*") do (
for /d %%j in ("C:\test2\*") do (
set srcdir="%%~nxi"
set destdir="%%~nxj"
if !srcdir! == !destdir! ( robocopy C:\test1 C:\test2 ) else (echo Notsame!)
echo %srcdir%
ping 130.11.160.2
)
)