General discussion

Locked

MS-DOS Batch Files

By archibald_j ·
I want to create a batch file that automates xcopy in DOS. I want to use the system date to create a directory with today's date and xcopy files into it. How do I use the system date to create a directory? I have done a complete script in UNIX and it works great. Any help would be appreciated. Thanks, John

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Creating a DOS directory

by Sean Reed In reply to MS-DOS Batch Files

According to "MS-DOS Batch File Programming 2nd Edition", chances are the best way would be to somehow save the output of DATE to a system variable. Then, once it's been saved, just issue an MD (or MKDIR) command specifieing whatever system variable you stored the date in.

For instance:
@echo off
date > %date%
md %date%
THEN your various xcopy commands.

Collapse -

Creating a Folder name datestamp with a

by jbridges In reply to Creating a DOS directory

This works for me.

:Begin
:: Extract the date and apply it to variables.

for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
set DayOfWeek=%%i
set Month=%%j
set Day=%%k
set Year=%%l
set Date=%%i %%j/%%k/%%l
)
rem scopyc:\hyperi~1\*.* E:\recover\cldate\Daily Backup /o /a /s
scopy c:\hyperi~1\*.* E:\recover\hyperbak\Daily /s

Exit
pause

Back to IT Employment Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums