file name to include time and date stamp plus file extension

  • Thread starter Thread starter Joe Vaughan
  • Start date Start date
J

Joe Vaughan

Is there a way to include a time/date/stamp in a file
name in Windows 2000. In other words, if I want to
create a file with the name to include the time and date
the file was created, how do I do that?

I've seen file names like 'myfile.timestamp.ext'.

myfile = my file name
timestamp = time and date file was created
ext = file type

Any suggestions?
 
Can you provide a sample timestamp?

I was able to use the %DATE% and %TIME% environment variables to get the
information, however the results contain characters which are not valid for
file names, so I would like to see what the timestamp format is that you are
looking for.
 
I receive a file via ftp once a day. The file name I get
is 'shorman.edi'. I want to retain a copy of this file
because I get a new one every day. I want to keep a copy
of the file in the same location I receive the file. But
when the next nights file arrives, it over-writes the
existing file. I'd like to be able to rename this file
through a batch job before the next nights download which
is scheduled through windows scheduler. here's an
example.

rename shorman.edi shorman.07102003.edi which includes
today date stamp.

I don't want the time. I just want the date. I need to
find a way to automate this process. Any ideas?





-----Original Message-----
Can you provide a sample timestamp?

I was able to use the %DATE% and %TIME% environment variables to get the
information, however the results contain characters which are not valid for
file names, so I would like to see what the timestamp format is that you are
looking for.
--
Bart Denison [MSFT]
This posting is provided "AS IS" with no warranties, and confers no rights.

Is there a way to include a time/date/stamp in a file
name in Windows 2000. In other words, if I want to
create a file with the name to include the time and date
the file was created, how do I do that?

I've seen file names like 'myfile.timestamp.ext'.

myfile = my file name
timestamp = time and date file was created
ext = file type

Any suggestions?


.
 
AWESOME! But can you explain to me what you're doing and
what each part of the syntax means?

ren shorman.edi shorman.%date:~10,4%%date:~4,2%%
date:~7,2%.edi
 
joe said:
can you also provide a good place for me to start in
learning about these command line features? Can you
recommend something? The help command does little for
me. But I try. Any books or classes or something?

Book: Tim Hill, _Windows NT Shell Scripting_

Web sites:

http://www.ss64.demon.co.uk/nt/
Simon Sheppard's WinNT Command Reference

http://www.robvanderwoude.com/
Rob van der Woude's Scripting Pages: Batch Files for DOS, Windows (all flavors), and OS/2

Newsgroups:

alt.msdos.batch.nt
microsoft.public.win2000.cmdprompt.admin

%date:~10,4% - substring of date, starting at the 10th character, for 4 characters = '2003'
%date:~4,2% - substring of date, starting at the 4th character, for 2 characters = '07'
%date:~7,2% - substring of date, starting at the 7th character, for 2 characters = '10'

(note: the base is zero, so the first character of date is %date:~0,1% = 'T')

0----+----1----+----2
Thu 07/10/2003

-----Original Message-----
Joe Vaughan wrote:

I receive a file via ftp once a day. The file name I
get

is 'shorman.edi'. I want to retain a copy of this
file

because I get a new one every day. I want to keep a
copy

of the file in the same location I receive the file.
But

when the next nights file arrives, it over-writes the
existing file. I'd like to be able to rename this
file
through a batch job before the next nights download
which

is scheduled through windows scheduler. here's an
example.

rename shorman.edi shorman.07102003.edi which
includes

today date stamp.

I don't want the time. I just want the date. I need
to

find a way to automate this process. Any ideas?

ren shorman.edi shorman.%date:~10,4%%date:~4,2%%
date:~7,2%.edi

(You'll be happier in the long run if you use yyyymmdd
rather

than mmddyyyy as the format.)








-----Original Message-----
Can you provide a sample timestamp?

I was able to use the %DATE% and %TIME% environment

variables to get the


information, however the results contain characters

which are not valid for


file names, so I would like to see what the timestamp

format is that you are


looking for.
--
Bart Denison [MSFT]
This posting is provided "AS IS" with no warranties,
and

confers no rights.



message




Is there a way to include a time/date/stamp in a file
name in Windows 2000. In other words, if I want to
create a file with the name to include the time and

date


the file was created, how do I do that?

I've seen file names like 'myfile.timestamp.ext'.

myfile = my file name
timestamp = time and date file was created
ext = file type

Any suggestions?


.



--
Phil Robyn
Univ. of California, Berkeley

u n z i p m y a d d r e s s t o s e n d e - m

a i l

.
 
Back
Top