Dos batch file
Discussion
In the good old days (10 years ago) I could probably have knocked this off without blinking. However working on many other (and better) OS I've forgotten.
Can anybody help me. O/S is win2K.
I need to provide a user with a simple way to copy her documents to a CD. (floppy disk too small). she backs up daily, and wants a history of the docs at the end of each day.
Now what I thought was a simple dos batch file could do this. What I want is something along the lines of:
get O/S date in format DD/MM/YY etc.
set variable xyz to be DDMMYY
create directory %xyz%
copy files to dir
done.
Now the problem I have are lines 1 and 2 above. How can I get the OS date and create a dir called DDMMYY ?
many thanks.
Can anybody help me. O/S is win2K.
I need to provide a user with a simple way to copy her documents to a CD. (floppy disk too small). she backs up daily, and wants a history of the docs at the end of each day.
Now what I thought was a simple dos batch file could do this. What I want is something along the lines of:
get O/S date in format DD/MM/YY etc.
set variable xyz to be DDMMYY
create directory %xyz%
copy files to dir
done.
Now the problem I have are lines 1 and 2 above. How can I get the OS date and create a dir called DDMMYY ?
many thanks.
I'm game!
This is a cross between DOS and another OS I know.
cd Documents and SettingsMy Documents
echo.
echo. %DATE%
echo.
echo Insert a CD
echo.
set D substr(%DATE%,4,2)
set M substr(%DATE%,6,2)
set Y substr(%DATE%,8,2)
set DMY concat(%D%%M%%Y%)
mkdir %DMY%
pause
verify on
copy *.doc d:\%DMY%
echo.
echo.
echo Backup complete. Check that there are no errors reported on screen here.
something along those lines......
This is a cross between DOS and another OS I know.
cd Documents and SettingsMy Documents
echo.
echo. %DATE%
echo.
echo Insert a CD
echo.
set D substr(%DATE%,4,2)
set M substr(%DATE%,6,2)
set Y substr(%DATE%,8,2)
set DMY concat(%D%%M%%Y%)
mkdir %DMY%
pause
verify on
copy *.doc d:\%DMY%
echo.
echo.
echo Backup complete. Check that there are no errors reported on screen here.
something along those lines......
Not sure that substr is valid in batch files, is it? Something like this would be dead easy in VBScript, though, and if she's running Windows 2000 I'd suggest that would be a better way.
If you do a quick google for scripting.filesystemobject you should see how to do the file copy, and googling for the datepart() function should help with converting the date to a string in the correct format.
The site www.devguru.com/technologies/vbscript/home.asp is a pretty handy resource for the various VBScript objects and functions.
If you do a quick google for scripting.filesystemobject you should see how to do the file copy, and googling for the datepart() function should help with converting the date to a string in the correct format.
The site www.devguru.com/technologies/vbscript/home.asp is a pretty handy resource for the various VBScript objects and functions.
Try this
for /f "tokens=1,2,3 delims=/" %%a in ('date /t') do set date=%%a%%b%%c
md %date%
CD %date%
This creates a directory called todays date in DDMMYYYY format and changes to that directory.
But once you've got the date variable filled with todays date everything else you need should be easy.
for /f "tokens=1,2,3 delims=/" %%a in ('date /t') do set date=%%a%%b%%c
md %date%
CD %date%
This creates a directory called todays date in DDMMYYYY format and changes to that directory.
But once you've got the date variable filled with todays date everything else you need should be easy.
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff



