I'm trying to write a batch file that copies folders from one folder location to another, but only if they exist in a third folder.
That sounds confusing, I'll try again.
I have the following 3 folders:
- Previous Versions
Before updating the
\Applications subfolder structure with the [new version]
\Updates subfolder structure, I need to copy the
\Applications subfolder structure to the
\Previous Versions folder. Once that is complete then it needs to copy the
Updates subfolder structure to the
I got as far as the following:
Setlocal EnableDelayedExpansion Set UpdtRoot=C:\Test\Updates Set AppsRoot=C:\Test\Apps Set PVerRoot=C:\Test\Previous Versions FOR /d %%i IN ("!UpdtRoot!\*.*") DO xcopy "!AppsRoot!\%%~nxi" "!PVerRoot!\%%~nxi\" /e
This doesn't work though, it copies all the folders from AppsRoot into PVerRoot.
I need it to copy subfolders from
PVerRoot, but only if they exist in
UpdtRoot. I only need it to copy the folders and subfolders ONLY so no files at all.