Solved

Script to copy files and create log of files copied

Posted on 2011-03-09
4
578 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 54

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

821 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