Solved

Script to copy files and create log of files copied

Posted on 2011-03-09
4
551 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
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 51

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 51

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now