Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Script to copy files and create log of files copied

Posted on 2011-03-09
4
Medium Priority
?
606 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 668 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 61

Assisted Solution

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

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

Assisted Solution

by:Bill Prew
Bill Prew earned 668 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

972 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