| 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: you need /O switch: 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. 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). |
|