Creating a log of files copied

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Contact:

Creating a log of files copied

Post by MigrationUser »

02 Dec 2007 04:11
Sockmaster1942


I'm pretty new to this and i've been playing around with it on my machine at home.
I'm curious, if i use a batch file to copy some files and folder and turn on verify is it possbile to make the batch file continue copying if the verify fails? and is it possible to make the batch file create a txt log of everything it copies and what fails ?

any help would be appreciated ^^, thanks in advance!

Never shall I quit, till I have a solution!... even if it kills me!!

----------------------------

#2 03 Dec 2007 01:59
zammalabe


command output and errors redirection are explained here: https://ss64.com/nt/syntax-redirection.html

----------------------------

#3 03 Dec 2007 03:05
Sockmaster1942


Okay sweet thanks alot!! that works great

lol, if you's don't mind, i'd also like to know how do to get the file name to be the current date ? I don't know if it's possbile but if it is, i'd like to know how plz.

Thank you for your previous answer ^^ and thanks to anyone who might be able to help a little for the next one

Never shall I quit, till I have a solution!... even if it kills me!!

----------------------------

#4 03 Dec 2007 07:19
zammalabe
Sockmaster1942 wrote:

lol, if you's don't mind, i'd also like to know how do to get the file name to be the current date ? I don't know if it's possbile but if it is, i'd like to know how plz.
the principle explained here: https://ss64.com/nt/syntax-variables.html
and here: https://ss64.com/nt/syntax-loops.html

in common:
* get variable (current date and/or time)
* create (or append to) a file with appropriate name
* redirect command output (probably in loop) into this file

exact examples how to get time/date are here: http://ss64.com/nt/syntax-getdate.html
and here: https://ss64.com/nt/syntax-gettime.html

... and for startup reading:
* commands: https://ss64.com/nt/
* syntanx: https://ss64.com/nt/syntax.html

Last edited by zammalabe (03 Dec 2007 07:23)

----------------------------

#5 03 Dec 2007 07:20
Sockmaster1942


^^ I've read most of whats on here https://ss64.com/nt/index.html but I'll have a look at the others now, thnx!

I was hoping to stay away from like programming code, I'm still getting used to the simple batch commands let alone the otha stuffs
____________________________________

Thanks but never mind I'm not smart enough to figure out how to get all that to work. laters

Last edited by Sockmaster1942 (03 Dec 2007 07:34)

Never shall I quit, till I have a solution!... even if it kills me!!

----------------------------

#6 03 Dec 2007 11:47
bluesxman


This is a simple example of a method one can use to get a file name using the current date:

Code: Select all

some.exe > "%date:/=%.log"
This simply uses the "DATE" system variable, performing a search and replace to remove the "/" symbols (thus resulting in a legal file name).

cmd | *sh | ruby | chef

----------------------------

#7 03 Dec 2007 21:17
zammalabe
Sockmaster1942 wrote:

lol, if you's don't mind, i'd also like to know how do to get the file name to be the current date ? I don't know if it's possbile but if it is, i'd like to know how plz.
as i don't know your file operation, what errors you want to log, those script should help you (lines wiht doulbe colon are ignored and for remarks)

Code: Select all

echo on

::define location of error log files
set ErrorLogFolder=C:\ErrorLogs\

::if ErrorLogFilder don't exist make it
if not exist %ErrorLogFolder% md %ErrorLogFolder%

::catch current path where you start this batch file as variable
set curdir1=%CD%

::catch current system date and time (, change the sequence of c,b,a and d,e according to your system date-time settings to get desirable output)
for /F "tokens=2,3,4 delims=.-/ " %%a in ('date /t') do set CurrDate=%%c%%b%%a
for /F "tokens=1,2 delims=: " %%d in ('time /t') do set CurrTime=%%d%%e

::display date-time variables
@echo system date is %CurrDate%
@echo system time is %CurrTime%

::make an empty file with the name datetimeError.log
set file1=%CurrDate%%CurrTime%Error.log
echo. >NUL 2>"%ErrorLogFolder%%file1%"

::in loop with elements [???] redirect all command [command] errors into previously created file
for %%i in [???] do %curdir1%\[some command] >> %ErrorLogFolder%file1%
Last edited by zammalabe (03 Dec 2007 21:19)

----------------------------

#8 07 Dec 2007 05:37
Sockmaster1942


:) :D !! it works hell good! Thank you ^^. :) :D :D

Mi operations vry simple

------

Code: Select all

Echo off
Echo *** V 1.2 ***
Echo Copying File from C drive to E drive. Copying Styles to E drive.
Echo on

cd\
verify on
xcopy /v /e /s /y C:\File E:\File
xcopy /v /e /s /y D:\Folder\Made\Styles E:\File\Folder\Made\Styles
verify off
------

thats is lol

Last edited by Sockmaster1942 (07 Dec 2007 05:43)
Post Reply