Dec 162017
 
4 ways to change date/time of file.
File DOSDATES.ZIP from The Programmer’s Corner in
Category Tutorials + Patches
4 ways to change date/time of file.
File Name File Size Zip Size Zip Type
DOSDATES.DOC 7552 2983 deflated

Download File DOSDATES.ZIP Here

Contents of the DOSDATES.DOC file


Stamp Collecting
(PC Magazine Vol 4 No 7 April 2, 1985 User-to-User)

The batch file, DT.BAT, redirects the date and time information
into a file or to a printer. To stamp a file, enter DT FILENAME. To
have the information appear on a listing, type DT PRN. So that you
don't have to press the Enter key when DOS asks for a new date and
time, create a file called CR that contains nothing except a carriage
return. To do this, type COPY CON:CR and then hit the Enter key twice,
then F6, and then the Enter key one more time. Then type:
COPY CON:DT.BAT
DATE%1
TIME%1
Hit the Enter key after each line, then F6 and the Enter key when
you're done. If you want one file with just the date and time, create
a DT1.BAT as follows:
COPY CON:DT1.BAT
DATEDATE
TIMETIME
COPY DATE+TIME %1
The prompts from both DATE and TIME are not redirected to the
output file. DT.BAT works properly if you're sending the output to a
printer, but the time stamp will write over the date stamp if you're
sending it to a disk file. DT1.BAT will work both if you send it to a
printer or a file.

-----------------------------------------------------------------
New Dates for Old
(PC Magazine Vol 4 No 21 Oct 15, 1985 User-to-User)

Here's a trick to put the current date and time stamp on any of
your files. Create a one-line batch file called STAMP.BAT with the
line: COPY %1/B,,+ %1 >NUL, where the ">NUL" suppresses spurious
messages that inclusion of the duplicate filespec generates. Then just
type: STAMP filename, substituting the name of the file whose date and
time you want to change for "filename." This also suppresses error
messages such as "File not found."
Editor's Note: This technique includes an improvement over the
example in the DOS manual -- the addition of a /B that forces DOS to
copy the entire length of the file as specified by the directory. If
you omit the /B and try this on a binary file with a ^Z(CHR$(26)) in
it, COPY will stop copying as soon as it hits this character, which
DOS assumes is a standard end-of-file marker. The /B will work both
for ASCII files and binary files. DOS defaults to /B when copying
without joining files together but defaults to /A when you ask COPY
to concatenate several files.
When DOS concatenates files (using +), it records the current
date and time in the directory. If you concatenate source files
without naming a result filename, COPY will add all the files it is
joining to the end of the first file in the list of filenames to be
joined. Since STAMP.BAT uses only one source name, and no result
names, the file is concatenated onto itself.
While DOS is strict about punctuation and syntax, the ,,+ works
as well as the +,, that the DOS manual uses. And, as the manual
points out, don't restamp all the files on your disk by using *.* in
place of the filename. Finally, STAMP.BAT will work fine without the
second %1.

-----------------------------------------------------------------
Dating Your Documents
(PC Magazine Vol 4 No 11 May 28, 1985 PC Tutor)

The simplest way to create on demand a kind of "date stamp" that
you can add to a document file is to type in the date yourself. If you
want to create a program to do this, use the DOS DATE command with
redirected input and output. This is a good way to learn about
redirection even if you don't use the program.
Consider a line such as:
A>DATETODAY
Here, CARRIAGE is a tiny text file that consists of one empty
line and a carriage return -- to simulate answering the DATE question
by pressing the enter key. The < sign before the word CARRIAGE is a
redirect symbol that means: use the file CARRIAGE as an input source
(instead of the keyboard). You can construct the CARRIAGE file with
the COPY command:
A>COPY CON:CARRIAGE


A>
For this application you only need to create CARRIAGE once and
then leave it on the disk. Note that the file is only 2 characters
long (a carraige return and a Ctrl-Z end-of-file marker), through it
may take up 1025 bytes on your disk.
The > sign before the word TODAY means that DOS will create a file
named TODAY, putting the output of DATE into the file. In current
jargon, the output of the program DATE has been "redirected" to the
file TODAY. Having created the CARRIAGE file, when you now type your
command:
DATETODAY
you will find a TODAY file has been created with the following lines in
it:
Current date is 5-28-85
Enter new date (mm-dd-yy):
This is exactly what DOS would have typed on the screen.
You can get a bit fancier and strip off the last line quite easily
using the DOS FIND program. It is a DOS program (not an intrinsic

command), so FIND.EXE would need to be on the disk. Instead of your
previous command line, type:
A>DATETODAY
Now the TODAY file will only retain the first line of the DATE result
-- the line containing the word "Current". This works by piping ( )
the output of DATE to the FIND program. FIND thus uses the output of
DATE instead of the keyboard for input. In this case, that looks like
two lines of text. FIND notices the word "Current" on line 1 and
passes it to the file TODAY. The second line has no such word and
therefore gets swallowed up.
If you are trying to integrate this with your word processor get
the startup (AUTOEXEC) routine to run the line that creates the TODAY
file. Almost every word processor will let you merge or include an
existing file (TODAY) with your current filt. Then your printout will
always contain a single line saying: Current date is Tue 5-28-1985 --
updated, of course, each day.
On a PC-XT under DOS 2.1, you don't need to use the DOS "pipe,"
FIND. The "Enter new date" appears on the screen only (and the carriage
return from CARRIAGE popped you past it) and was not transferred to the
TODAY file.

-----------------------------------------------------------------
In Search of Lost Time
(PC Magazine Vol 4 No 25 Dec 10, 1985 PC Tutor)

Persons tired of seeing lists of files dated 1/1/80 might want to
use the DATECHK.COM file. DATECHK.COM returns an "error" code that
equals the year set in DOS minus 1980. The batch file fragment shown
below which you can add to your AUTOEXEC.BAT file to run when you
boot up, uses this error code with an ERRORLEVEL check to continually
ask for the date if it's still set at 1980.

echo off
cls
:getdate
date
datechk
if errorlevel 1 goto gooddate
echo Gimme a break ....
echo It's not 1980 anymore.
goto getdate
:gooddate

DATECHK.COM:

A>DEBUG
-A
xxxx:0100 MOV AH,2A
xxxx:0102 INT 21
xxxx:0104 MOV AX,CX
xxxx:0106 SUB AX,7BC
xxxx:0109 MOV AH,4C
xxxx:010B INT 21
xxxx:010D
-N DATECHK.COM
-R CX
CX 0000
:000D
-W
Writing 000D bytes
-Q


 December 16, 2017  Add comments

Leave a Reply