Batch file to create report.txt file for xcopy

J

jatman

i am using the following batch file, that works for the basic back up on XP,
SP2

cd C:\Operations\Forms (source folder)
rasdial.exe vpn username passwd (establish VPN)
echo %date%, %time% VPN Established > Report.txt (records date, time of VPN
connection)
set folder=%date:~0,2% (sets the folder name to the day of the week, Mo, Tu,
We, ... to be used on the destination drive)
net use "\\...\" (maps the drive)
xcopy c: \\server\pll065\%folder% /s /e /h /D (copies, source to destination.)
rasdial.exe test /disconnect (disconnects VPN)
echo %date%, %time% VPN Disconnected >> Report.txt (records VPN
disconnection in Report.txt file)
shutdown -r

all of this works pretty good, but there are two things that i cannot get it
to do:
first, the reports file writes over itself. How can i change it so that it
does not write over itself, but either adds to the existing file or creates a
new file with a date stamp in the title (either way will work, but prefer
just adding to the existing file.)

i tried the line:
echo %date%, %time%, VPN established > copy con report.txt
but this did not work. i also tired it without the ">" and no luck either.
(copy con is supposed to use the next available line, but i could be wrong.)

the second thing, i would like it to do is list any files that were updated
(if any.) the xcopy command shows the file names that are updated/backed up,
and at the end, how many were backed up. can this be sent to the same
report.txt?

ultimately, the report.txt should look like this:

date, time, vpn established (done)
file1.doc
file2.doc
file3.xls
3 files copied
date, time, vpn disconnected (done)

and the next time either it continues from there, or a new file. really
sounds easy, but i cannot get the last two things figured out.

any help is appreciated.

thank you,

jat
 
J

jatman

i can rename the file, at the end using:

for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "Report.txt"
%%f-%%e-%%d.txt

but if i update more than once a day (i get a duplicate file error, so i
thought i'd add the time as follows:

for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "Report.txt"
%%f-%%e-%%d,%time%.txt

but i get an error message indicating that the syntax of the command is
incorrect.

further, but still need help.

jat
 
A

AlmostBob

echo fred > fred text
overwrites

echo fred >> fred.txt
appends

--
Adaware http://www.lavasoft.de
spybot http://www.safer-networking.org
AVG free antivirus http://www.grisoft.com
Etrust/Vet/CA.online Antivirus scan
http://www3.ca.com/securityadvisor/virusinfo/scan.aspx
Panda online AntiVirus scan http://www.pandasoftware.com/ActiveScan/
Catalog of removal tools (1)
http://www.pandasoftware.com/download/utilities/
Catalog of removal tools (2)
http://www3.ca.com/securityadvisor/newsinfo/collateral.aspx?CID=40387
Blocking Unwanted Parasites with a Hosts file
http://mvps.org/winhelp2002/hosts.htm
links provided as a courtesy, read all instructions on the pages before use

Grateful thanks to the authors and webmasters
_
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top