Solved

Script to copy files and create log of files copied

Posted on 2011-03-09
4
595 Views
Last Modified: 2012-05-11
I need a script to create a folder on a Log Server and then copy files from one Server into that folder. I need it to create a .txt file listing all the files copied but save that file in a different location. Here is the script I'm using now, so if we can just make additions to this it would be great!!!

@echo off
set T=%time:~0,5%
set dir=%date:/=-% %T::=-%
echo The target folder is "%dir%".
xcopy /s /c /y "D:\GCTI\Logs\KSC_SIP_Agent_1_Bac\Archive\*.*" "\\usmoksc5app55\logs\usmoksc5app10\%dir%\"
0
Comment
Question by:charlespliler
[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
4 Comments
 
LVL 3

Accepted Solution

by:
4runnerfun earned 167 total points
ID: 35084459
at the end of your xcopy line, add >>"path and name of log file"

i.e.
xcopy /s /c /y "D:\GCTI\Logs\KSC_SIP_Agent_1_Bac\Archive\*.*" "\\usmoksc5app55\logs\usmoksc5app10\%dir%\" >> "\\mysharedlocation\mylog.log"
0
 
LVL 56

Assisted Solution

by:HainKurt
HainKurt earned 166 total points
ID: 35084499
or after xcopy use

dir /b "\\usmoksc5app55\logs\usmoksc5app10\%dir%\" >> "\\mysharedlocation\mylog.log"
0
 
LVL 56

Assisted Solution

by:Bill Prew
Bill Prew earned 167 total points
ID: 35084634
Adding on to 4runnerfun post, I would also add the following after that suggestion, so that you are capturing both normal output messages (STDOUT) ad well as any error messages (STDERR).

xcopy /s /c /y "D:\GCTI\Logs\KSC_SIP_Agent_1_Bac\Archive\*.*" "\\usmoksc5app55\logs\usmoksc5app10\%dir%\" >> "\\mysharedlocation\mylog.log" 2>&1

~bp
0
 

Author Closing Comment

by:charlespliler
ID: 35084785
Thanks so much for the quick response
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

636 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