Solved

Logging in a batch script

Posted on 2008-10-27
3
306 Views
Last Modified: 2012-05-05
Hi, have added the following commands at the end of my batch script
Rem Store backup Script
net use e: /d


rem Store - 001
ping 10.10.10.2
net use e: \\10.10.10.2\2007 /user:admin password
f:
copy *.* d:\storedata\001\ /y


net use e: /d /y
date /t >>d:\storedata\backuplog.txt
time /t >>d:\storedata\backuplog.txt

end

Would it be possible to log how much data has copied or to log the size of folder after it has been copied? (d:\storedata\001)
0
Comment
Question by:Dan560
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 250 total points
ID: 22812074

Try:


DIR d:\storedata\001\ >>d:\storedata\backuplog.txt

Open in new window

0
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 250 total points
ID: 22812151
If you just want the total of the files then do

dir D:\storedata\001 /s | find "Dir(s)" >>d:\storedata\backuplog.txt

Depends upon your needs but easy enough to add a bit more logging if you want with some echo statements etc:

Steve

@echo off
Rem Store backup Script
echo %date% %time% Backup started >> d:\storedata\backuplog.txt
echo ... %date% %time% Removing old drive mapping  >> d:\storedata\backuplog.txt
net use e: /d  >> d:\storedata\backuplog.txt 2>>&1
ping 10.10.10.2
echo ... %date% %time% Mapping drive >> d:\storedata\backuplog.txt
net use e: \\10.10.10.2\2007 /user:admin password  >> d:\storedata\backuplog.txt 2>>&1
f:
echo ... %date% %time% Starting copy >> d:\storedata\backuplog.txt
copy *.* d:\storedata\001\ /y  >> d:\storedata\backuplog.txt 2>>&1
net use e: /d /y
dir D:\storedata\001 /s | find "Dir(s)" >>d:\storedata\backuplog.txt
echo %date% %time% Backup completed >> d:\storedata\backuplog.txt

0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 22812164
To make it look less busy add

set log=d:\storedata\backuplog.txt

at the beginning and replace all the d:\storedata\backuplog.txt entries with %log%

Steve

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

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

830 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