| 1. |
Solve : Listing names of files created in the current week? |
|
Answer» Hi - I have a situation where I have to get the list of all file names created in the CURRENT week. is there a way i can do thisyou can use vbscript which has better date and time support. eg Code: [Select]Set objFSO=CreateObject("Scripting.FileSystemObject") Set objFolderA=objFSO.GetFolder("C:\folder") strFolderB="C:\destination" For Each strfile in objFolderA.Files If dateDiff("d", file.DateCreated, Date) < 7 Then objFSO.CopyFile strfile.Path, strFolderB End If Next Set objFSO=Nothing or alternatively , you can use GNU Win32 unix tools, like find eg Code: [Select]C:\test>find c:/test -type f -mtime -7 | sed "s|\/|\\|g" c:\test\new you can put this inside a batch file. Quote also can you point some good sites with batch programming tutorials. i coulndt find much on this siteType in "batch programming tutorials" in google for a start.i needed it in pure dos no vb scripting or unix commandsQuote from: hp_tvm on January 14, 2008, 08:08:59 AM i needed it in pure dostoo bad thenAs mentioned batch code does not do date arithmetic unless you are prepared to write a boatload of if statements. If you just need a list, try using XCOPY: Code: [Select]xcopy * c:\windows\temp /L /d:01-07-2008 You'll have to change the date manually (today - 7 days). No actual copy operation takes place, the code lists the files that would have been copied had you not used the /l switch. |
|