Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple command line questions - dos :-)

Status
Not open for further replies.

basball

Technical User
Dec 18, 2002
192
US
I'm using a simple command line expression using xcopy in a bat file which is scheduled so i can copy my files from server 'a' to 'b' it would be nice if could create a destination directory with a random generated file name, so i won't overwrite my exisiting data each time. i suspect i could find an app to do this, but don't want to pay for it, or perhaps someone knows of a free app to do this.
more preferable would be a destination directory with
date + time code stamp.

xcopy c:\*.* /y /s \\station0x

the 'y' prevents prompt if same file name exists and s is to copy all directories, excluding empty ones.
 
Here is the batch command that will create a directory of today's date (mmddyyyy) on server called DATA with a share called DATA. Then copy the file test.bat to that directory

This should be a good starting point for you to work from.

@ECHO OFF
FOR /F "tokens=1-4 delims=/ " %%I IN ('DATE /t') DO SET mydate=%%J%%K%%L
md \\data\data\"%mydate%"
copy c:\test.bat \\data\data\%mydate%
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top