use DIR to list folder content older than 10 years.

how do I use the DIR command to list content of a folder older than 10 years?  

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
Also look at command forfiles.exe included with windows.  I don't have my PC and can't give you the syntax.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bill PrewCommented:
You can't do this with the basic built in DOS DIR command, there are no options to select by date.  You could do it with a batch file, here's an example of that.  Save as a BAT file and adjust the folder name.

(We could do this fairly easily in a VBS script too, let me know if you want to see that)

@echo off
setlocal EnableDelayedExpansion

REM Change to folder with files to check
pushd c:\temp

REM Calculate date 10 years ago in YYYYMMDD format
set CutoffDate=%DATE:~-4%%DATE:~-10,2%%DATE:~-7,2%
set /a CutoffDate=%CutoffDate-100000

REM CHeck all files in the folder
for %%F in (*.*) do (

  REM Put file date in YYYYMMDD format
  set FileDate=%%~tF
  set FileDate=!FileDate:~6,4!!FileDate:~0,2!!FileDate:~-3,2!

  REM If file is older than 10 years then diplay it with it's date stamp
  if !FileDate! LSS %CutoffDate% (
    echo %%~tF  %%~F

REM Return to original folder

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.