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

Posted on 2011-09-23
Last Modified: 2012-05-12
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!

Question by:mystikal1000
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 33

Accepted Solution

knightEknight earned 500 total points
ID: 36589258
@echo off

cd/d "c:\apps"

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

LVL 33

Expert Comment

ID: 36589263
The above script will create a new sub-directory for each server listed in servers.txt.

Featured Post

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A brief introduction to what I consider to be the best editor for PowerShell.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question