1.

Solve : Listing files created or modified on a certain date?

Answer»

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?

ThanksCode: [Select]DIR /s /o /p /d=05-12-2009Are you sure of that syntax?
Which version of DOS?Code: [Select]DIR /S /P /O D=05-12-2009should workVersion 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?

Thanksyou need /O switch:

Code: [Select]DIR /O D=05-12-2009Quote from: devcom on May 12, 2009, 11:33:28 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.

i was reading dir /? to fast and didnt chcek it, sry for that, and i think for loop will be good hereuse 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.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) copiedxxcopy 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).


Discussion

No Comment Found