Solved

Script to copy files and create log of files copied

Posted on 2011-03-09
4
589 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 53

Assisted Solution

by:Huseyin KAHRAMAN
Huseyin KAHRAMAN 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

710 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