Computing.Net > Forums > Programming > Display modified on last 3 days

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Display modified on last 3 days

Reply to Message Icon

Name: KyserSlick
Date: April 3, 2008 at 04:38:25 Pacific
OS: XP
CPU/Ram: 2GHz
Product: HP
Comment:

I would like to use DIR on a batch file to only pick the files modified on the last three days



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: April 3, 2008 at 05:14:14 Pacific
Reply:

you can do a vbscript. or if you can download and install findutils for windows here : http://gnuwin32.sourceforge.net/pac...

you can use it to find files modified during the last 3 days


c:\test> find c:\path -type f -mtime -3 -print


0

Response Number 2
Name: KyserSlick
Date: April 3, 2008 at 05:29:54 Pacific
Reply:

Thanx ghostdog,

I already have my batch file that does quite some work on existing files, but I need to filter files to work only on last modified ones instead of working on all the files on a folder.


0

Response Number 3
Name: ghostdog
Date: April 3, 2008 at 05:49:25 Pacific
Reply:

you can incorporate find in your batch file too. Unless you have a restriction of downloading and installing third party tools.


0

Response Number 4
Name: KyserSlick
Date: April 3, 2008 at 06:52:42 Pacific
Reply:

That's unfortunately the case, I have already thaught about third party soft to incorporate that functionality but I'm not allowad to install anything on the production server


0

Response Number 5
Name: Razor2.3
Date: April 7, 2008 at 20:33:09 Pacific
Reply:

I agree; it's much safer to run random scripts you get from anonymous people in an online Internet forum on a production environment.

This VBScript will list all files in a directory you specify modified within the number of days you specify, with 0 being today. This script goes by calendar days, not 24 hours == 1 day; failure to specify means I'm left guessing. It'll write to standard out if you use CSCRIPT; out.txt if not. While this script isn't my best work, it'll do.

If WScript.Arguments.Unnamed.Count = 0 Then _
WScript.Quit 1

chkDate = WScript.Arguments.Named.Exists("time")
If chkDate Then
cutoff = CDate(Int(Now) - WScript.Arguments.Named("time"))
Else
cutoff = 0
End If

With CreateObject("Scripting.FileSystemObject")
On Error Resume Next
WScript.StdOut.WriteLine ""
If Err = 0 Then
Set out = WScript.StdOut
Else
Err.Clear
Set out = .CreateTextFile("out.txt", True)
If Err > 0 Then _
WScript.Quit 255
End If
On Error GoTo 0

For Each f In .GetFolder(WScript.Arguments.Unnamed(0)).Files
If Not chkDate Or f.DateLastModified >= cutoff Then _
out.WriteLine f
Next
End With

Suggested use:

CSCRIPT <script>.vbs //NOLOGO <path> /time:3


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Display modified on last 3 days

display bitmap on screen www.computing.net/answers/programming/display-bitmap-on-screen/2680.html

Unable to reinstall Visual Studio 6 www.computing.net/answers/programming/unable-to-reinstall-visual-studio-6/17392.html

Programming Tutorial Update www.computing.net/answers/programming/programming-tutorial-update/7266.html