Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Displaying the file creation date  (Read 7843 times)

0 Members and 1 Guest are viewing this topic.

AlexTheGrater

    Topic Starter


    Greenhorn

    Displaying the file creation date
    « 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.

    Reno



      Hopeful
    • Thanked: 32
      Re: Displaying the file creation date
      « Reply #1 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

      Bulwark



        Beginner
      • I love YaBB 1G - SP1!
        Re: Displaying the file creation date
        « Reply #2 on: May 01, 2009, 01:18:45 AM »
         ???

        In MS-Dos 6.22  ???

        Reno



          Hopeful
        • Thanked: 32
          Re: Displaying the file creation date
          « Reply #3 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.

          Geek-9pm


            Mastermind
          • Geek After Dark
          • Thanked: 1026
            • Gekk9pm bnlog
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 10
          Re: Displaying the file creation date
          « Reply #4 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.

          gh0std0g74



            Apprentice

            Thanked: 37
            Re: Displaying the file creation date
            « Reply #5 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?

            AlexTheGrater

              Topic Starter


              Greenhorn

              Re: Displaying the file creation date
              « Reply #6 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?

              gh0std0g74



                Apprentice

                Thanked: 37
                Re: Displaying the file creation date
                « Reply #7 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?

                Geek-9pm


                  Mastermind
                • Geek After Dark
                • Thanked: 1026
                  • Gekk9pm bnlog
                • Certifications: List
                • Computer: Specs
                • Experience: Expert
                • OS: Windows 10
                Re: Displaying the file creation date
                « Reply #8 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 ?


                Dias de verano

                • Guest
                Re: Displaying the file creation date
                « Reply #9 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.


                macdad-



                  Expert

                  Thanked: 40
                  Re: Displaying the file creation date
                  « Reply #10 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-)
                  If you dont know DOS, you dont know Windows...

                  Thats why Bill Gates created the Windows NT Family.

                  Dias de verano

                  • Guest
                  Re: Displaying the file creation date
                  « Reply #11 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?




                  macdad-



                    Expert

                    Thanked: 40
                    Re: Displaying the file creation date
                    « Reply #12 on: May 05, 2009, 12:12:12 PM »
                    My fault...

                    If you dont know DOS, you dont know Windows...

                    Thats why Bill Gates created the Windows NT Family.

                    Dias de verano

                    • Guest
                    Re: Displaying the file creation date
                    « Reply #13 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


                    BC_Programmer


                      Mastermind
                    • Typing is no substitute for thinking.
                    • Thanked: 1140
                      • Yes
                      • Yes
                      • BC-Programming.com
                    • Certifications: List
                    • Computer: Specs
                    • Experience: Beginner
                    • OS: Windows 11
                    Re: Displaying the file creation date
                    « Reply #14 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.
                    I was trying to dereference Null Pointers before it was cool.

                    Dias de verano

                    • Guest
                    Re: Displaying the file creation date
                    « Reply #15 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.






                    AlexTheGrater

                      Topic Starter


                      Greenhorn

                      Re: Displaying the file creation date
                      « Reply #16 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. 

                      Dias de verano

                      • Guest
                      Re: Displaying the file creation date
                      « Reply #17 on: May 06, 2009, 04:40:40 AM »
                      Have you tried my QBasic solution?

                      AlexTheGrater

                        Topic Starter


                        Greenhorn

                        Re: Displaying the file creation date
                        « Reply #18 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,

                        AlexTheGrater

                          Topic Starter


                          Greenhorn

                          Re: Displaying the file creation date
                          « Reply #19 on: May 07, 2009, 10:11:27 AM »
                          Sorry Dias, just seen your Qbasic solution, I'll give it a try, eternal thanks.

                          Dias de verano

                          • Guest
                          Re: Displaying the file creation date
                          « Reply #20 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


                          AlexTheGrater

                            Topic Starter


                            Greenhorn

                            Re: Displaying the file creation date
                            « Reply #21 on: May 07, 2009, 01:59:50 PM »
                            Thanks, Diaz.  It works!  You're a star..