-1

We want to copy a folder from multiple PCs in a master PC for backup

We have the following code:

cd C:\Users\magazin\Desktop\Scripts\Test_Lorin\swcom_script
del results.txt
for /F %i in (PC.txt) do (
  copy /R /Y /S "\\%i\d$\SWCOM" "\\%i\d$\Swcom_old" /EXCLUDE:C:\Users\magazin\Desktop\Scripts\Test_Lorin\swcom_script\exclusion.txt
  if ERRORLEVEL 1 echo %i >> results.txt
 )
_____________________________________________________
cd C:\Users\magazin\Desktop\Scripts\Test_Lorin\swcom_script
del results.txt
for /F %i in (PC.txt) do = **will copy on PCs with IPs file written PC.txt**
____________________________________________________
xcopy /R /Y /S "\\%i\d$\SWCOM" "\\%i\d$\Swcom_old" = **the source and destination **
_____________________________________________________
/EXCLUDE:C:\Users\magazin\Desktop\Scripts\Test_Lorin\swcom_script\exclusion.txt = will ignore folders file written exclusion.txt

The problem is: we need a code to create a new folder for each PC on which to copy those files.

We have over 100 PCs should have 100 different folders on each PC, and the name of those folders to be ip where it comes from.

GrizzlyManBear
  • 647
  • 8
  • 16

1 Answers1

0

In your destination, use

"\\%i\d$\%COMPUTERNAME%\Swcom_old"

"\\%i\d$\Swcom_old"

which hould record the computername as part of the directory structure - assuming that each computer has a different name...

Magoo
  • 77,302
  • 8
  • 62
  • 84