Solved

Batch Command DATE & USERNAME vars

Posted on 2003-10-23
8
1,712 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
  • 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

803 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