How to list folders that don't contain recently created files

charvett
charvett used Ask the Experts™
on
Hello,

I'm trying to do some housekeeping on a number of folders. I'd like to have a batch file that will list folders that have no files created in the last X number of days.

For example, I'd like to list all the folders that haven't had any new files added to it in the last 30 days. That way I can identify folders that are not active.

A simple command line or batch file would be ideal. It's on a Windows 2005 Server.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I tend to use VBScript to do file system operations of this sort.  Batch is fine for basic stuff, but VBS offers a much richer library of functions.  Date comparisons is a good example.
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
Are all the folders children of a common parent?  So you want to search all the subfolders of a single parent folder?

~bp
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
And what if there are nested folders, like:

dir1
   dir2
      file2-1
      file2-2
      dir3
        file3-1
        file3-2

and in dir2, file2-1 and file2-2 have not been changed in 30 days, but let's say file3-1 has been changed in less than 30 days.  Would dir2 get deleted or not?

~bp
Acronis in Gartner 2019 MQ for datacenter backup

It is an honor to be featured in Gartner 2019 Magic Quadrant for Datacenter Backup and Recovery Solutions. Gartner’s MQ sets a high standard and earning a place on their grid is a great affirmation that Acronis is delivering on our mission to protect all data, apps, and systems.

Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
Also, can you post up the output of two things, from a command line.

ECHO %DATE%

and then just a DIR on a couple of files.

I want to see the format of the date that your system is using.

~bp

Author

Commented:
Hello,

Thanks for the follow up. There are no nested folders, only a list of one deep folders with files in each.

The date format is: Thu 05/19/2011

Thanks!
Commented:
HI,

You can use robocopy command for retreiving the required data,

Try below command and let me know if any further help required,

robocopy "folder location" "folder location" /MINAGE:30 /L /E > "log_file_path"

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial