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

Author Topic: Listing files created or modified on a certain date  (Read 12525 times)

0 Members and 1 Guest are viewing this topic.

aanvd

    Topic Starter


    Newbie

    Listing files created or modified on a certain date
    « on: May 12, 2009, 10:48:01 AM »
    In the old MS-DOS there was a way to LIST ONLY the files created in a certain time window for instance 2009-05-11 to 2009-05-12 using the /D switch. For instance:

    DIR /s /o /p /d=05-12-2009

    However that does not work under command prompt. Can anyone suggest how I could accomplish that?

    Thanks

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Listing files created or modified on a certain date
    « Reply #1 on: May 12, 2009, 11:09:32 AM »
    Code: [Select]
    DIR /s /o /p /d=05-12-2009Are you sure of that syntax?
    Which version of DOS?

    devcom



      Apprentice

      Thanked: 37
      Re: Listing files created or modified on a certain date
      « Reply #2 on: May 12, 2009, 11:10:30 AM »
      Code: [Select]
      DIR /S /P /O D=05-12-2009should work
      Download: Choice.exe

      aanvd

        Topic Starter


        Newbie

        Re: Listing files created or modified on a certain date
        « Reply #3 on: May 12, 2009, 11:29:04 AM »
        Version of DOS: I am not sure, it was a long time ago but it had to be 6.0 or earlier.

        DIR D=01-31-2008     did not work (I used that date totest because there is a file with that date in the directory.)

        Any other suggestions?

        Thanks

        devcom



          Apprentice

          Thanked: 37
          Re: Listing files created or modified on a certain date
          « Reply #4 on: May 12, 2009, 11:33:28 AM »
          you need /O switch:

          Code: [Select]
          DIR /O D=05-12-2009
          Download: Choice.exe

          Dias de verano

          • Guest
          Re: Listing files created or modified on a certain date
          « Reply #5 on: May 12, 2009, 11:41:18 AM »
          you need /O switch:

          Code: [Select]
          DIR /O D=05-12-2009

          which version has that /d=MM-DD-YYYY switch? Because I've never seen it and I started with MS-DOS 3.30.

          I believe aanvd may be misremembering.


          devcom



            Apprentice

            Thanked: 37
            Re: Listing files created or modified on a certain date
            « Reply #6 on: May 12, 2009, 12:09:32 PM »
            i was reading dir /? to fast and didnt chcek it, sry for that, and i think for loop will be good here
            Download: Choice.exe

            gh0std0g74



              Apprentice

              Thanked: 37
              Re: Listing files created or modified on a certain date
              « Reply #7 on: May 12, 2009, 06:19:35 PM »
              use vbscript
              Code: [Select]
              Set objFS = CreateObject("Scripting.FileSystemObject")
              strFolder = "c:\test"
              Set objFolder = objFS.GetFolder(strFolder)
              For Each strFile In objFolder.Files
              strDate = FormatDateTime(strFile.DateCreated,vbShortDate)
                  If strDate = "5/12/2009" Or strDate = "5/13/2009" Then
                  WScript.Echo strFile.Name
                  End If
              Next

              save as myscript.vbs and on command prompt
              Code: [Select]
              c:\test> cscript /nologo myscript.vbs

              if you want to do in batch, use the for loop with delim and tokens set ,  go over dir /tc, get the creation date, compare with what date you want and echo out the result.

              Reno



                Hopeful
              • Thanked: 32
                Re: Listing files created or modified on a certain date
                « Reply #8 on: May 13, 2009, 12:14:23 AM »
                something similar to /d switch is the xcopy
                Quote
                  /D:m-d-y     Copies files changed on or after the specified date.
                               If no date is given, copies only those files whose
                               source time is newer than the destination time.

                the code:
                Code: [Select]
                C:\>md fakedir

                C:\>echo.nnnnnnnnnnnnnn|xcopy *.txt fakedir /d:05-1-09/p
                C:filename.txt (Y/N)? n
                C:index.txt (Y/N)? n
                C:n10.txt (Y/N)? n
                C:newfile.txt (Y/N)? n
                C:order.txt (Y/N)? n
                C:save.txt (Y/N)? n
                C:seven 7.TXT (Y/N)? n
                C:sevench.txt (Y/N)? n
                C:test.txt (Y/N)? n
                0 File(s) copied

                Dias de verano

                • Guest
                Re: Listing files created or modified on a certain date
                « Reply #9 on: May 13, 2009, 12:26:41 AM »
                xxcopy is free for personal use, has syntax which is a superset of xcopy, has a "list files which would be copied" mode (like xcopy), and crucially considering the original question, can be instructed to work with a date range. (unlike xcopy).