Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

Program to list all dirs, subdirs and files older than 1 year

Thread view: 
Prime - 14 Dec 2005 16:33 GMT
Hello,

Anyone know of a program or class that takes in a directory,
recursively scans that directory for any files or subdirectories for a
criteria, (say over 1 year old), and then can output those file names?

Thank you!
Patrick
Monique Y. Mudama - 14 Dec 2005 16:45 GMT
> Hello,
>
[quoted text clipped - 4 lines]
>
> Thank you!  Patrick

Does it need to be multi-platform?  Because that sounds like a job for
some scripts in a shell environment.

Signature

monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html

Prime - 14 Dec 2005 17:43 GMT
Monique:

multiplatform would be best, as the environment is windows but might
eventually switch to Red Hat.

Patrick
Abhijat Vatsyayan - 14 Dec 2005 18:02 GMT
Haven't tested it but something like (you will definitely need to modify
this)-

    public static void listDirs(Collection fileCollection, File
baseDir,           FileFilter filter)
    {
        File children[] = baseDir.listFiles(filter);
        for (int i = 0; i < children.length; i++)
        {
            File childFile = children[i];
            if(childFile.isDirectory())
            {
                listDirs(fileCollection,childFile,filter);
            }
            fileCollection.add(childFile);
        }
    }
I do not know how this will work for symbolic links (infinite loops!).
> Hello,
>
[quoted text clipped - 4 lines]
> Thank you!
> Patrick
Gordon Beaton - 14 Dec 2005 18:03 GMT
> Anyone know of a program or class that takes in a directory,
> recursively scans that directory for any files or subdirectories for
> a criteria, (say over 1 year old), and then can output those file
> names?

GNU find, like this:

 find . -mtime +365

http://www.gnu.org/software/findutils/findutils.html

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e

Prime - 14 Dec 2005 20:42 GMT
Thank you everyone!
iamfractal@hotmail.com - 15 Dec 2005 08:56 GMT
>From the source's mouth:

http://www.javapractices.com/Topic68.cjp

.ed

--
www.EdmundKirwan.com - Home of The Fractal Class Composition.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.