Solved

Batch Command DATE & USERNAME vars

Posted on 2003-10-23
8
1,735 Views
Last Modified: 2013-12-28
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 ???


0
Comment
Question by:neilhoman
[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
  • 2
  • 2
8 Comments
 

Author Comment

by:neilhoman
ID: 9606431
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
 
LVL 1

Expert Comment

by:btomgrant
ID: 9619363
Hmmmm this is something I tried to do unsuccsesfully yesterday. I want to post so I can steal the answer.    Good luck!

Btomgrant
0
 
LVL 1

Expert Comment

by:lacams
ID: 9632653
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:neilhoman
ID: 9633455
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
 
LVL 1

Expert Comment

by:lacams
ID: 9633785
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
 
LVL 1

Accepted Solution

by:
btomgrant earned 250 total points
ID: 9639310
Download this little utility called doff.exe from http://www.jfitz.com/dos/  and use their batch commands --  KISS method.

btomgrant
0
 

Author Comment

by:neilhoman
ID: 9641732
Having a look at doff now.

thanx for your comment,
-Neil
0
 

Author Comment

by:neilhoman
ID: 9641843
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

Featured Post

Don't Miss ATEN at InfoComm 2017!

Visit booth #2167 to see the  new ATEN VM3200 32 x 32 Modular Matrix Switch. Other highlights include the VE8950 4K HDMI Over IP Extender, VS1912 12-Port DP Video Wall Media Player  and VK2100 ATEN Control System. Register now with Free Pass Code ATEN288!

Question has a verified solution.

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

Determining the an SCCM package name from the Package ID
When asking a question in a forum or creating documentation, screenshots are vital tools that can convey a lot more information and save you and your reader a lot of time
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

695 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