Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

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
0
mystikal1000
Asked:
mystikal1000
  • 2
1 Solution
 
knightEknightCommented:
@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

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now