Computing.Net > Forums > Windows 2000 > Batch file for current date

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file for current date

Reply to Message Icon

Name: Noor2000
Date: August 27, 2004 at 12:37:39 Pacific
OS: 2000
CPU/Ram: 256
Comment:

Hi every body,
I have an issue, so every day i have to format a floppy and to label it with the current date in the format:YYYYMMDD. I would like to write a batch file to automate that, but I don't know how to read the date in this format and how to assign it to the floppy?
Any idea?
Thanks
Noor(technicalUser)



Sponsored Link
Ads by Google

Response Number 1
Name: stroke6463
Date: August 27, 2004 at 13:57:34 Pacific
Reply:

This should work. Just copy and paste what is between the lines and save it with the .bat extension. I am assuming that your floppy drive is a: if not just make the change.
_______________________________________________________
@echo off
for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set year=%%c
for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set month=%%a
for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set day=%%b
set temp=%year%%month%%day%
label a: %temp%
_______________________________________________________
It worked for me, if it doesn't work for you please let me know and I can try to give you another idea. Either way keep me posted because I want to make sure it worked properly. Good luck.



0

Response Number 2
Name: FishMonger
Date: August 27, 2004 at 19:56:32 Pacific
Reply:

Here's a shorter methoed.

set mydate=%date:~10%%date:~4,2%%date:~7,2%
echo %mydate%


0

Response Number 3
Name: FishMonger
Date: August 27, 2004 at 20:03:40 Pacific
Reply:

I forgot to mention that the method I showed will work in both Windows and DOS systems. Pat's method, which is probably more common, only works in Windows.


0

Response Number 4
Name: Mechanix2Go
Date: August 28, 2004 at 01:03:23 Pacific
Reply:

Hi,

Fish, yours didn't do anything in w2k cmd. And I think Pat's will only work in 2k~xp with command extensions enabled.

Pat, yeah, but, probably not a good idea to alter the %temp% ; that can have, as they say "unintended consequences."

Noor,

format a: /v:%DATEvar%



0

Response Number 5
Name: FishMonger
Date: August 28, 2004 at 06:55:21 Pacific
Reply:

C:\testing>ver

Microsoft Windows 2000 [Version 5.00.2195]

C:\testing>type noor2000.bat
@echo off

set mydate=%date:~10%%date:~4,2%%date:~7,2%
echo %mydate%

C:\testing>noor2000.bat
20040828

C:\testing>


0

Related Posts

See More



Response Number 6
Name: Noor2000
Date: August 28, 2004 at 09:13:11 Pacific
Reply:

Thank you guys for your help. I tried the method of Fish and Pat. The problem I have when I double click on the script from Windows It didn't work, if I open a Dos windows and then I execute the script from Dos both of them work.

Is it normal or I am making a mistake somewhere?

Thanks
Noor(Technicaluser)


0

Response Number 7
Name: Mechanix2Go
Date: August 28, 2004 at 09:28:34 Pacific
Reply:

Hi Fish,

Thanks. I learned something. My date format is different.

M2

Mechanix2Go@Golden-Triangle.com


0

Response Number 8
Name: Noor2000
Date: August 28, 2004 at 09:51:58 Pacific
Reply:

It works, I tried again and It is okey
Thank you all
The last thing, I'm a beginner in batch files and I would like to know more, is there any links that can help me
Thanks
Noor


0

Response Number 9
Name: Mechanix2Go
Date: August 29, 2004 at 00:15:31 Pacific
Reply:

Noor,

http://users.accesscomm.ca/gbraun/batch/rant.htm#manifest
http://www.fpschultze.de/bsc.htm
http://www.techtutorials.info/dbatch.html

M2

Mechanix2Go@Golden-Triangle.com


0

Response Number 10
Name: nudesign
Date: August 31, 2004 at 09:27:38 Pacific
Reply:

using the most unreliable date storage type too! use a cd-r. ten a penny nowadays! just as easy to drag and drop also


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Windows 2000 Forum Home


Sponsored links

Ads by Google


Results for: Batch file for current date

Batch Files for Login Script Not Working www.computing.net/answers/windows-2000/batch-files-for-login-script-not-working/32923.html

batch files on Win2000 www.computing.net/answers/windows-2000/batch-files-on-win2000/49666.html

About writing batch file for NTbackup www.computing.net/answers/windows-2000/about-writing-batch-file-for-ntbackup/34002.html