-3

I am trying to copy test and test1 folder under %%e ("QA_ENDORSEMENT") since the folder name is varying.

filename QA_ENDORSEMENT sometimes varies

But I cannot get it done using my code below.

for /f "usebackq delims=" %%e in (`dir /b C:\BACKUPS\UAT`) do (
    xcopy "C:\BACKUPS\UAT\%%e\*" "C:\inetpub\wwwroot\" /F /E)
Eryk Sun
  • 33,190
  • 5
  • 92
  • 111
Koya JSev
  • 25
  • 5
  • are you trying to copy only specific folders or all folders in a directory? – Gerhard May 31 '17 at 07:21
  • are you basically looking at copying everything from ` C:\BACKUPS\UAT\QA_ENDORSEMENT\` or just folders `test` and `test1` from `QA_ENDOREMENT` – Gerhard May 31 '17 at 07:44
  • I am trying to copy all folders under QA_ENDORSEMENT. but QA_ENDORSEMENT is varying – Koya JSev May 31 '17 at 08:58

1 Answers1

0

This will copy anything within C:\BACKUPS\UAT\*\

So if you have C:\BACKUPS\UAT\QA_ENDORSEMENT\test it will copy test and its subdirectories and files to c:\inetpub\wwwroot but if you have C:\BACKUPS\UAT\ANOTHER\anotherfolder it will also copy anotherfolder and its sub directories to c:\inetpub\wwwroot

for /f %%e in ('dir /b C:\BACKUPS\UAT\*') do (xcopy "C:\BACKUPS\UAT\%%e\*" "C:\inetpub\wwwroot\" /Y /F /E)

Basically you will copy anything inside the subfolders of C:\BACKUPS\UAT\* but excluding the actual QA_ENDORSEMENT directory or others in UAT themselves.

Gerhard
  • 22,678
  • 7
  • 27
  • 43