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.
All these FILES will be created in the same directory.

ANy pointers will be appreciatedBatch files cannot really do date arithmetic; and what exactly do you mean by current week ? the last 7 days or since Sunday (or Saturday) ?

I strongly recommend this Microsoft tool http://www.iis.net/downloads/default.aspx?tabid=34&i=1287&g=6 This is Logparser and can do some powerful manipulation - but even then, Id be hard pressed to tell you how to identify the current week as defined by 'since Sunday'.

Otherwise, you need to use vbscript to identify the files.

Grahamhi - the batch program should take the current date and display all the files created in the last 7 days from the current date. I want to do this as a pure batch program. the files are of the format f_x_timestamp.txt etc

is there a way i can do this

also can you point some good sites with batch programming tutorials. i coulndt find much on this siteQuote from: hp_tvm on JANUARY 14, 2008, 07:32:17 AM

is there a way i can do this
you 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 site
Type 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 dos
no vb scripting or unix commands
too 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.




Discussion

No Comment Found