1

I need to get a list of directories older than 90 days from 'today's' date using windows command line so I can schedule a batch file to run these folders through a separate process.

I need to list folders and subfolders only, no files.

I have tried using 'dir' which produces the list I need:

dir /b /s /a:d /o:gen >C:\file_list.txt

But, I can't check for dates greater than X using 'dir'.

I've looked at using 'forfiles' but this won't produce the list as I need it which my dir attempt produces.

To add some more complexity, ideally I need to check the date on the files within a folder rather than the folders date properties.

Any help is greatly appreciated, thanks.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
  • Please read the tag info before you add tags! [tag:dos] and [tag:ms-dos] do definitely not apply here are `forfiles` was introduced in Windows... – aschipfl Jul 18 '16 at 15:14
  • What do you want exactly: a list of directories, or a list of files? is the sort order relevant? – aschipfl Jul 18 '16 at 15:26
  • Related: [Batch file to delete files older than N days](http://stackoverflow.com/a/51069) – aschipfl Jul 18 '16 at 15:28

1 Answers1

1

And if you try with Forfiles like that :

@echo off
set OLD=90
FORFILES /S /D -%OLD% /C "cmd /c IF @isdir == TRUE echo @path"
pause

For more information about Forfiles command

Hackoo
  • 18,337
  • 3
  • 40
  • 70