Computing.Net > Forums > Disk Operating System > batch for

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

batch for

Reply to Message Icon

Original Message
Name: josh
Date: July 23, 2002 at 23:24:26 Pacific
Subject: batch for
Comment:

i currently have a batch file that will pull the system date and display it in the MMDDYYYY format. i then use this piece of code in various activities such as renaming files, makeing directories, etc.

does anyone have any idea how to pull 'yesterdays' date? or any other ideas how to change what i currently have. this is my current code, im running it off a win 98 machine.

:: Get current date into %date% variable without separators
@echo off
echo @PROMPT SET DATE=$D$_> %temp%.\temp.bat
%comspec% /c %temp%.\temp.bat > %temp%.\temp2.bat
echo.> %temp%.\temp.bat
for %%? in (e111''3B e114''3B w q) do echo %%?>> %temp%.\temp.bat
DEBUG %temp%.\temp2.bat nul
call %temp%.\temp2.bat
:: Next line defines date format. The values generally are:
:: %%1=Week day %%2=Month %%3=Date %%4=Year (4 digits)
:: Those could change, depending mainly on the COUNTRY
:: command (from config.sys).
echo SET DAY=%%3> %temp%.\temp.bat
call %temp%.\temp.bat;%date%
echo %day%
echo SET DATE=%%2%%3%%4> %temp%.\temp.bat
call %temp%.\temp.bat;%date%
for %%? in (temp.bat temp2.bat) do if exist %temp%.\%%? del %temp%.\%%?
echo %date%


Report Offensive Message For Removal


Response Number 1
Name: Renaissance Man
Date: July 24, 2002 at 06:41:15 Pacific
Reply: (edit)

Secret Doom from
http://www.computing.net/dos/wwwboard/forum/10849.html

That script will get today's and yesterday's date into the variables %TODAY% and %YESTERDAY%. The format is MM/DD/YYYY, but that can be changed (read commented lines).

That script is only for NT systems. In order to do such a thing in Win9x, I would store today's date to be used tomorrow, instead of calculating yesterday's date.


Report Offensive Follow Up For Removal

Response Number 2
Name: josh
Date: July 24, 2002 at 22:35:22 Pacific
Reply: (edit)

yes i had found that script earlier, but i dont have win nt on my computer. everything i have tried for calculating yesterdays date has not turned out well. i can get todays date with no trouble, how might i store the date from the variable and then retrieve it back into a variable when it is again needed?


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge
Poll History




Data Recovery Software