Solved

problems with win 2000 bat file using %date%

Posted on 2003-11-28
9
240 Views
Last Modified: 2010-04-14
Hi,

I am running windows 2000 Pro. When I access the command prompt and type the command %date%

I am returned the message: 'Fri' is not recognized as an internal or exteral command, operable programme or batch file

I want to use %date% in a .bat file I am creating to create a files on a daily basis named the current date.

'Fri' obviously relates to today which is a Friday but I do not want the day I just want the date in the format 28-11-03 not Fri 28-11-03.

How can I change the system to stop the Fri being generated which is stopping my .bat file from running.

Many thanks,

Tom Gribbin
<Email address removed by SerCouWisMOD pursuant of http://www.experts-exchange.com/help/mistakes.jsp#2 >
0
Comment
Question by:tomgribbin
  • 4
9 Comments
 
LVL 24

Expert Comment

by:shivsa
ID: 9838652
solve this problem by creating a variable named "date" and put the current date into that variable. use this command at the beginning of the batch file:

for /f  "delims==" %%G IN ('date /t') do set date=%%G

now when you'll write %date% (within the batch file you'll recieve the date)
0
 
LVL 33

Expert Comment

by:MikeKane
ID: 9838653
I had a similiar issue.   I use 2 old com files called getmonth.com and getday.com and I create batchfiles that do something like the following:


GETMONTH
IF ERRORLEVEL 1 IF NOT ERRORLEVEL 2 SET MMDD=01
IF ERRORLEVEL 2 IF NOT ERRORLEVEL 3 SET MMDD=02
etc..etc...all the way to 12

then
GETDAY
IF ERRORLEVEL 1 IF NOT ERRORLEVEL 2 SET MMDD=%MMDD%01
IF ERRORLEVEL 2 IF NOT ERRORLEVEL 3 SET MMDD=%MMDD%02
etc...  all the way to 31  

this worked well in NT and 2k.  


0
 
LVL 24

Expert Comment

by:shivsa
ID: 9838659
or like this
FOR /f "tokens=2-4 delims=/ " %%a in ('date /t') do set date=%%a%%b%%c
If you want your date in different format, you can rearrange the variables a, b and c.
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:tomgribbin
ID: 9838684
Shivsa,

Thanks for your swift reply. the code for batch file is below. where and how would i inser the variable which you mention? Sorry for being dim - batch file follows:

cd\
copy e:\datamain.xls e:\dailystats\
rename e:\dailystats\datamain.xls e:\dailystats\%date%.xls

Cheers
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9838700
for /f "tokens=1,2,3,4 delims=/ " %%a in ('date /t') do set today=%%b-%%c-%%d
%today% will have the format u asked for.
0
 
LVL 24

Accepted Solution

by:
shivsa earned 125 total points
ID: 9838708
cd\
copy e:\datamain.xls e:\dailystats\
for /f "tokens=1,2,3,4 delims=/ " %%a in ('date /t') do set today=%%b-%%c-%%d
rename e:\dailystats\datamain.xls e:\dailystats\%today%.xls
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Update a root certificate 8 677
VBScript not processed at Windows 8.1 logon 2 8,012
Domain dunctional level. 4 324
Windows SBS 2003 filling up disk with NTbackup files 6 180
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
There's a lot of hype surrounding blockchain technology. Here's how it works and some of the novel ways it' s now being used - including for data protection.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 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