Solved

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

Posted on 2011-09-23
2
299 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
  • 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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