automate file searches

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I was wondering if there was an easy way to automate a file search.
Specifically, I'm looking to do something like this: execute a search at
midnight to find all files modified on the D: drive during the previous day.
Ideally, the output would go to a text file that I can then view in the
morning.

I currently do this using the gui, but it takes a while to search through
the large number of files. Also, the output tends to change during the
search as people modify files on the drive. I was thinking of something like
dir /od, except that would list all the files on the drive, instead of just
those modified during the previous day. Are there any other command line
tools I can use for this?

Thank you,
Mike
 
Hello,

I was wondering if there was an easy way to automate a file search.
Specifically, I'm looking to do something like this: execute a search at
midnight to find all files modified on the D: drive during the previous day.
Ideally, the output would go to a text file that I can then view in the
morning.

I currently do this using the gui, but it takes a while to search through
the large number of files. Also, the output tends to change during the
search as people modify files on the drive. I was thinking of something like
dir /od, except that would list all the files on the drive, instead of just
those modified during the previous day. Are there any other command line
tools I can use for this?

Thank you,
Mike


Schedule one of the following batches, which uses DatePorM.bat from tip 8293 in the 'Tips & Tricks' at http://www.jsiinc.com

This batch relies on the archive bit being set. A full backup will unset it.
@echo off
setlocal
If exist c:\folder\Yesterday.txt del /q c:\folder\Yesterday.txt
call DatePorM -1 Yesterday
for /f "Tokens=*" %%f in ('dir D: /b /s /aa') do (
call :test "%%f"
)
endlocal
goto :EOF
:test
for /f "Tokens=1*" %%y in ('dir %1 /TW^|find /I "%~nx1"') do (
if "%%y" EQU "%Yesterday%" @echo %1>>c:\folder\Yesterday.txt
)

This batch runs longer, but doesn't test the archive bit:
@echo off
setlocal
If exist c:\folder\Yesterday.txt del /q c:\folder\Yesterday.txt
call DatePorM -1 Yesterday
for /f "Tokens=*" %%f in ('dir D: /b /s ') do (
call :test "%%f"
)
endlocal
goto :EOF
:test
for /f "Tokens=1*" %%y in ('dir %1 /TW^|find /I "%~nx1"') do (
if "%%y" EQU "%Yesterday%" @echo %1>>c:\folder\Yesterday.txt
)

Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Back
Top