Batch Command DATE & USERNAME vars

Hello there experts,
I have approx 15 users using a piece of client software for on of our apps in here.
One of the files for this s/w needs to be backed up regularly.
Being lazy I do not really want to visit all these machines.
I have set up a batch file which I have placed on each users desktop which copies new versions of the software. So that any time a change is made double clicking on the file will copy the updated s/w to their machines.
I was thinkin I could place a file in their statup menu so that when they start their computers up it would copy the the file (the one that needs to be backed up) to a remote location.

i need the script for a batch file that will copy a file to a remote location and rename it to file_%Username%_%Date%.
Where Username is the username of the currently logged in user
and
date is the date (no need for time).

so it would have the effect of producing this command :
copy d:\file.txt \\someserver\bckups\file_neil_23_10_2003.txt

Any ideas folks ???


neilhomanAsked:
Who is Participating?
 
btomgrantCommented:
Download this little utility called doff.exe from http://www.jfitz.com/dos/  and use their batch commands --  KISS method.

btomgrant
0
 
neilhomanAuthor Commented:
It is also important to mention that users are running NT/2000/95.

Just to make things difficult.

thanks in advance for any comments.

-Neil
0
 
btomgrantCommented:
Hmmmm this is something I tried to do unsuccsesfully yesterday. I want to post so I can steal the answer.    Good luck!

Btomgrant
0
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.

 
lacamsCommented:
script that make that :

for /F "tokens=2-4 delims=/ " %%f in ('date /T') do copy C:\essai\test.txt C:\essai\test_%USERNAME%_%%f_%%g_%%h.txt

christophe
0
 
neilhomanAuthor Commented:
I pasted the following at the command prompt :

for /F "tokens=2-4 delims=/ " %%f in ('date /T') do copy C:\essai\test.txt C:\essai\test_%USERNAME%_%%f_%%g_%%h.txt


but I got the following :

%%f was unexpected at this time.

this was on windows nt.

I am trying a few varations now.

-N

0
 
lacamsCommented:
Try with the brackets after the 'Do' :

for /F "tokens=2-4 delims=/ " %%f in ('date /T') do (copy C:\essai\test.txt C:\essai\test_%USERNAME%_%%f_%%g_%%h.txt)

christophe


0
 
neilhomanAuthor Commented:
Having a look at doff now.

thanx for your comment,
-Neil
0
 
neilhomanAuthor Commented:
Here's the solution that appears to be working on NT & 2K.... I havent tried W9x yet.

@echo off
for /f "tokens=1-3 delims=/ " %%a in ('doff mm/dd/yyyy -1') do (
set mm=%%a
set dd=%%b
set yyyy=%%c)
set UN=%USERNAME%
copy file.txt file-%UN%-%dd%%mm%%yyyy%.txt

This copies the file file.txt to another file with the username and date postfixed.

It means that I can get all users to backup there files to one central share.

I will be accepting btomgrant's question as an answer but thanks to all for the help,

-Neil
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.