Search file and folder based on date created

I am looking for a way to find out how to search a partition for all files and folders based on the date range they are created.

For example: I want all folders created between 1/1/2011 and 1/31/2011. How should I go about that?
dishelpAsked:
Who is Participating?
 
ReneGeConnect With a Mentor Commented:
Here is how I would do this.

I did not test it so I'm sure it's buggy

PS: hey bp!

 
@ECHO OFF

SETLOCAL enabledelayedexpansion

SET OutputFile=%~n0.log
SET DirToScan=C:\Temp

SET DateMin=1/1/2011
SET DateMax=1/31/2011

CALL :ConvertJulian DateMin %DateMin%
CALL :ConvertJulian DateMax %DateMax%

FOR /F "delims=" %%A in ('dir /b /s /ad "%DirToScan%"') DO (
	SET Folderdate=%%~tA
	CALL :ConvertJulian Folderdate !Folderdate!
	IF %Folderdate% GEQ %DateMin% IF %Folderdate% LEQ %DateMax% ECHO %%~fA>>"%OutputFile%"
)

EXIT

:ConvertJulian
FOR /F "tokens=1-3 delims=/" %%A IN (%~1) DO (
	SET DayVal=%%B
	SET MonthVal=%%A
	SET YearVal=%%C
)

REM CONVERT DATE TO JULIAN
	SET /a "YearJ=10000%YearVal% %%10000,MonthJ=100%MonthVal% %% 100,DayJ=100%DayVal% %% 100"
	SET /a %~2=DayJ-32075+1461*(YearJ+4800+(MonthJ-14)/12)/4+367*(MonthJ-2-(MonthJ-14)/12*12)/12-3*((YearJ+4900+(MonthJ-14)/12)/100)/4
	
EXIT /b

Open in new window

0
 
aavictorCommented:
For 50 points,

1.  Use  DIR to obtain information and store in file
DIR /S /a:d >  C:\folderInfo.txt

2. Manually use MS WORD to "highligh" the dates you want if the number you guess is great
    or fast reading
0
 
Bill PrewCommented:
That's going to be very hard (but not impossible, but likely not worth only 50 points) to do in a pure BAT file script.  Batch scripting doesn't have good support for dates, so comparing dates to see if they fall in a range takes more than a few lines of code.

Does this have to be a DOS batch script, or couse a VBS (vb script) solution work, it has much better date comparing capabilities.

~bp
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
dishelpAuthor Commented:
Hello billprew,

Sorry, I'm not sure about the point system before and I wasn't clear on the difficulty. Any suggestion what I should put down for the point value? Any help would be greatly appreciated. I'm fairly new to this :)

As long as it works, we have no preference if it's VBS or DOS Batch.

Thanks in advance.
0
 
zhshqzycCommented:
I think that it is very hard, at least 500 points.
0
 
Bill PrewCommented:
"For example: I want all folders created between 1/1/2011 and 1/31/2011. How should I go about that?"

So, do you just want a list of the folders?  None of the files contained in them?

Do you have any other needs?

~bp

0
 
Bill PrewCommented:
@dishelp

Awaiting further clarification...

~bp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.