Solved

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

Posted on 2011-09-23
2
300 Views
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!

Thanks
0
Comment
Question by:mystikal1000
[X]
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
2 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 500 total points
ID: 36589258
@echo off
setlocal

cd/d "c:\apps"

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

0
 
LVL 33

Expert Comment

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

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