Computer Hope
Microsoft => Microsoft DOS => Topic started 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.
-
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:
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
-
???
In MS-Dos 6.22 ???
-
???
In MS-Dos 6.22 ???
oops, sorry, didn't notice that part?
i dont have ms-dos 6.22 to try.
-
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.
-
its probably none of my business but why are you still using MSDOS 6.22 after 15 years?
-
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?
-
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?
-
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 ?
-
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.
-
Or just good 'ol FOR? ;)
@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-)
-
Or just good 'ol FOR? ;)
No good. Have you read the thread & seen where it says he's using MS-DOS 6.22?
-
My fault...
-
(part of) a batch file
dir filename.txt > dirline.txt
qbasic /run filedate.bas
del dirline.txt
filedate.bas
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
-
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.
-
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.
-
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.
-
Have you tried my QBasic solution?
-
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,
-
Sorry Dias, just seen your Qbasic solution, I'll give it a try, eternal thanks.
-
just seen your Qbasic solution
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
-
Thanks, Diaz. It works! You're a star..