Computer Hope

Microsoft => Microsoft DOS => Topic started by: AlexTheGrater on May 01, 2009, 12:38:16 AM

Title: Displaying the file creation date
Post by: AlexTheGrater on May 01, 2009, 12:38:16 AM
I'd like to echo the file creation date of a specific file on the screen without displaying the file name or other details, can you help?

The message to read "File created on dd/mm/yyyy"

Be gentle, it's my first posting!

I have browsed all the threads, but found nothing.

I'm using MS-DOS 6.22, and I'm rediscovering batch files after 15 years in the wilderness.
Title: Re: Displaying the file creation date
Post by: Reno on May 01, 2009, 01:00:43 AM
Code: [Select]
if wsh.arguments.count=0 then wsh.echo "Usage:",wscript.scriptname,"filename":wsh.quit 1
d=createobject("scripting.filesystemobject").getfile(wsh.arguments(0)).datecreated
d=right("0"&day(d),2) & "/" & right("0"&month(d),2) & "/" & year(d)
wsh.echo "File created on",d

save the above as for example createdate.vbs
then on command prompt type createdate filename.ext

example output:
Code: [Select]
C:\>createdate createdate.vbs
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

File created on 01/05/2009

C:\>cscript//nologo createdate.vbs test.txt
File created on 17/04/2009
Title: Re: Displaying the file creation date
Post by: Bulwark on May 01, 2009, 01:18:45 AM
 ???

In MS-Dos 6.22  ???
Title: Re: Displaying the file creation date
Post by: Reno on May 01, 2009, 03:04:52 AM
???

In MS-Dos 6.22  ???

oops, sorry, didn't notice that part?
i dont have ms-dos 6.22 to try.
Title: Re: Displaying the file creation date
Post by: Geek-9pm on May 01, 2009, 03:47:23 AM
MS-DOS Bootable ISO images.
http://www.bootdisks.us/ms-dos/5/ms-dos-bootable-cd-images.html
Boot from the CD as A:
Use floppy as B: for program storage.
Title: Re: Displaying the file creation date
Post by: gh0std0g74 on May 01, 2009, 09:24:49 AM
its probably none of my business but why are you still using MSDOS 6.22 after 15 years?
Title: Re: Displaying the file creation date
Post by: AlexTheGrater on May 04, 2009, 01:16:54 PM
Hi all, yes it's DOS 6.22, and it's used (I think) because of it's stability, and that is what was available when this particular spectrometer was designed.  There's no reason to change if it works, why would the program be rewritten for Windows, more expense, less stability?
Title: Re: Displaying the file creation date
Post by: gh0std0g74 on May 04, 2009, 06:15:18 PM
why would the program be rewritten for Windows, more expense, less stability?
because of reasons like what you have posted? requirement changes? in the past you don't need to find out about creation date, but now you do, and then you found out that DOS6.22 doesn't have the facility to allow that? worse, you went to search for a third party tool and found it does the work you want, but is not written to be run on DOS6.22 because its too old? are these valid reasons for you?
Title: Re: Displaying the file creation date
Post by: Geek-9pm on May 04, 2009, 11:48:56 PM


Hey, AlexTheGrater

Your reasons are valid. If it works, don't change it.

You can get your creation dates from you backup system.
Make a daily backup of all files that have been modified. You will have a trail that will help you find the creations date and all the modifications dates.

Or you can create a program that will find new files on the system and log the creation date into a database. This is not much help for work you have already done, but in the future you will have a log of when a file was created.

Do you an old DOS version of Lotus 123?
Or maybe Framework 2 ?

Title: Re: Displaying the file creation date
Post by: Dias de verano on May 05, 2009, 12:53:07 AM
If QBasic is present it would be possible to DIR to a text file then dissect the DIR output and just display the creation date.

Title: Re: Displaying the file creation date
Post by: macdad- on May 05, 2009, 06:11:43 AM
Or just good 'ol FOR?  ;)

Code: [Select]
@echo off
for /f %%A in (textfile.txt) do (
echo File Name: %~nxA
echo File Created: %~tA
echo File Size: %~zA
)
pause

If you need other details echoed about the file just name 'em.

Hope this helps
,Nick(macdad-)
Title: Re: Displaying the file creation date
Post by: Dias de verano on May 05, 2009, 06:39:33 AM
Or just good 'ol FOR?  ;)

No good. Have you read the thread & seen where it says he's using MS-DOS 6.22?



Title: Re: Displaying the file creation date
Post by: macdad- on May 05, 2009, 12:12:12 PM
My fault...

Title: Re: Displaying the file creation date
Post by: Dias de verano on May 05, 2009, 01:56:51 PM
(part of) a batch file

Code: [Select]

dir filename.txt > dirline.txt
qbasic /run filedate.bas
del dirline.txt


filedate.bas

Code: [Select]

open "dirline.txt" for input as #1
for j=1 to 5: line input #1, d$:next j
line input #1, a$
print "File created on "; MID$(a$, 29, 10)
system

Title: Re: Displaying the file creation date
Post by: BC_Programmer on May 05, 2009, 02:05:18 PM
does DOS even maintain both the modified AND created dates? I'm not sure I remember correctly.

But if they do- the results still could be misleading. over 80% of the programs which accessed files in those days would often erase the original file and save it again- causing both the created and modified dates to always be equal.
Title: Re: Displaying the file creation date
Post by: Dias de verano on May 05, 2009, 02:17:26 PM
does DOS even maintain both the modified AND created dates? I'm not sure I remember correctly.

There is no created date in MS-DOS 6.22. Version 7.10 and later can store creation/modified but only when LFNs are enabled.





Title: Re: Displaying the file creation date
Post by: AlexTheGrater on May 06, 2009, 02:17:30 AM
because of reasons like what you have posted? requirement changes? in the past you don't need to find out about creation date, but now you do, and then you found out that DOS6.22 doesn't have the facility to allow that? worse, you went to search for a third party tool and found it does the work you want, but is not written to be run on DOS6.22 because its too old? are these valid reasons for you?
Wow, steady.. Do you have anger issues with MS-DOS?  I looked for a third party tool, did I?  I was not aware that I'd done that. 
Title: Re: Displaying the file creation date
Post by: Dias de verano on May 06, 2009, 04:40:40 AM
Have you tried my QBasic solution?
Title: Re: Displaying the file creation date
Post by: AlexTheGrater on May 07, 2009, 10:07:02 AM
Hi Dias,

Thanks for the query, could I trouble you for a few pointers on dissecting the text file (I can direct it to the file ok, but to get chunks back may involve a bit of heartache)

Thanks for taking the time to respond, I appreciate the 'help each other out' attitude some people have.  I'm not sure if there's any way I can help you out..

All the best,
Title: Re: Displaying the file creation date
Post by: AlexTheGrater on May 07, 2009, 10:11:27 AM
Sorry Dias, just seen your Qbasic solution, I'll give it a try, eternal thanks.
Title: Re: Displaying the file creation date
Post by: Dias de verano on May 07, 2009, 10:27:37 AM
just seen your Qbasic solution

Code: [Select]
REM Open the file previously created
REM Which has the output of DIR
open "dirline.txt" for input as #1

REM skip over the first 5 lines of the DIR output
for j=1 to 5: line input #1, d$:next j

REM Get the next line
line input #1, a$

REM I omitted this, it is probably good housekeeping
REM to close the file
close #1

REM Show the part of the line with the date / time info
REM that is, the 10 characters starting at position 29
print "File created on "; MID$(a$, 29, 10)

REM exit back to batch file
system

Title: Re: Displaying the file creation date
Post by: AlexTheGrater on May 07, 2009, 01:59:50 PM
Thanks, Diaz.  It works!  You're a star..