Home / Microsoft / Microsoft DOS / Listing names of files created in the current week
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: Listing names of files created in the current week  (Read 1081 times)
hp_tvm
Guest
« on: January 14, 2008, 04:55:35 AM »

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 appreciated
IP logged
gpl
Apprentice



Thanked: 25
Posts: 547




« Reply #1 on: January 14, 2008, 07:13:04 AM »

Batch 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.

Graham
IP logged
hp_tvm
Guest
« Reply #2 on: January 14, 2008, 07:32:17 AM »

hi - 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 site
IP logged
ghostdog74
Mentor



Thanked: 26
Posts: 1,511


« Reply #3 on: January 14, 2008, 08:06:31 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.
IP logged

hp_tvm
Guest
« Reply #4 on: January 14, 2008, 08:08:59 AM »

i needed it in pure dos
no vb scripting or unix commands
IP logged
ghostdog74
Mentor



Thanked: 26
Posts: 1,511


« Reply #5 on: January 14, 2008, 08:13:40 AM »

i needed it in pure dos
no vb scripting or unix commands
too bad then
IP logged

Sidewinder
Guru



Thanked: 97
Posts: 4,342

Experience: Familiar
OS: Windows 7

« Reply #6 on: January 14, 2008, 04:03:02 PM »

As 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.

 8)
IP logged

If you don't know where you are going, any road will get you there

                                                                            -Lewis Carroll
Pages: [1] - (Top) Print 
Home / Microsoft / Microsoft DOS / Listing names of files created in the current week « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 5.089 seconds with 20 queries.