How to create a directory named "currentdate" using a bat file

T

Testy

Hi,
Im trying to write a w2k script line (to be used in a automated ftp bat
file) that creates a directory named "thecurrentdate"

I thought it would something like...
md %date% or md %D%-%MM%-%YYYY%

What am I doing wrong please??

Further, If you find that easy... how do you add the time?

Thanks alot o wise ones
Testy
 
P

Phil Robyn

Testy said:
Hi,
Im trying to write a w2k script line (to be used in a automated ftp bat
file) that creates a directory named "thecurrentdate"

I thought it would something like...
md %date% or md %D%-%MM%-%YYYY%

What am I doing wrong please??

Further, If you find that easy... how do you add the time?

Thanks alot o wise ones
Testy

md "\%date:~10,4%-%date:~4,2%-%date:~7,2% %time::=-%"
 
T

Testy

Hey thanks for that Phil that was really helpfull. Ive seen you answer a
fair number of the posts here. How do I reorganise that to be 28-07-2003 ??
Is that possible?
Thanks heaps
Testy
(Sydney, Aus)
 
P

Phil Robyn

Testy said:
Hey thanks for that Phil that was really helpfull. Ive seen you answer a
fair number of the posts here. How do I reorganise that to be 28-07-2003 ??
Is that possible?
Thanks heaps
Testy
(Sydney, Aus)

Move the substrings of '%date%' around so that they are in the order
you desire. If the value of '%date%' is 'Sun 07/27/2003', then
'%date:~4,2%' is '07', '%date:~7,2%' is '27', and (you guessed it)
'%date:~10,4%' is '2003'. The value of '%date:~0,3%' is 'Sun'.
 
G

guard

Testy said:
Im trying to write a w2k script line (to be used in a automated ftp bat
file) that creates a directory named "thecurrentdate"

Mount/\Commands give you several different choices for using the date and
time in file names (or anywhere else that you need to). They all work
CONSISTENTLY across NT/2K/XP/K3 using only what is available "out of the
box".

The following examples use the "Interactive Mode" of the Mount/\Command Set.
Specifically the "." (aka "dot") command.

*******

C:\GuardPost>.
Type ". [prefix]" for a list of .Mount/\Commands -OR- ". Command" to
execute.

C:\GuardPost>. get
..GetCD
..GetCodePage
..GetCols
..GetDate
..GetFree
..GetFreeM
..GetIPAddr
..GetIPGateway
..GetIPMask
..GetLines
..GetLogDate
..GetLogTime
..GetLogTimeP
..GetMac
..GetNic
..GetOS
..GetPrompt
..GetRole
..GetTempFile
..GetTime
..GetTimeP

C:\GuardPost>. GetLogDate
20030730

C:\GuardPost>set #LogDate
#LogDate=20030730

C:\GuardPost>. ZeroFile %#LogDate%.txt

C:\GuardPost>dir /b *.txt
20030730.txt

C:\GuardPost>. GetLogTime
092255

C:\GuardPost>. ZeroFile %#LogTime%.txt

C:\GuardPost>dir /b *.txt
20030730.txt
092255.txt

C:\GuardPost>. GetLogTimeP
09225606

C:\GuardPost>. ZeroFile %#LogDate%-%#LogTimeP%.txt

C:\GuardPost>dir /b *.txt
20030730.txt
092255.txt
20030730-09225606.txt

C:\GuardPost>

*******

In a script, the commands above would be:

%.GetLogDate%
%.ZeroFile% %#LogDate%.txt

%.GetLogTime%
%.ZeroFile% %#LogTime%.txt

%.GetLogTimeP%
%.ZeroFile% %#LogDate%-%#LogTimeP%.txt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top