Script to Copy Files/Folder in a directory - Batch Script

I need help asap.

I need a script that will copy a folder and any file/subdirectory below it to a destination folder for multiple server names.  I want the script to look at a servers.txt file of all servers and then perform its copy for each server name specified in the TXT file.

Source:  \\server1\apps\logs\
Destination: c:\apps

After its done copying, I want the destination folder to be named the server name.

I will reward points asap!

Thanks
LVL 1
mystikal1000Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
knightEknightConnect With a Mentor Commented:
@echo off
setlocal

cd/d "c:\apps"

for /f %%S in (servers.txt) do (
  md "%%S"
  xcopy/e "\\%%S\apps\logs\"  "%%S"
)

0
 
knightEknightCommented:
The above script will create a new sub-directory for each server listed in servers.txt.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.