Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems
Finding Modified dir's top level (Windows

Posted by hugo_owen (hugo_owen), 28 June 2006
I need to find if any files have been modified within a directory structure. problem is that if you modify a files 5 dir's down it does not modify the top level directory only the parent one level up.

So I think I need to chk for all files recursively but then I will just get a huge long list of files, I only really want to know if files have been modified within top level directory and below recursively.

Posted by admin (Graham Ellis), 28 June 2006
Have a look here - an old example that recursively goes through a file system structure at or below a chosen directory, and reports only on huge files.

You can change the -s to -M or -C to check file ages, and then act as appropriate - perhaps push all the recent names that you're looking for onto a list ...

Posted by hugo_owen (hugo_owen), 28 June 2006
thanks Graham, I do use this all the time to find files and it works great but in this scenario I want the perl script to just tell me if only the top level dir has been modified if a file 20 levels down has been modified: e.g



if I change a file in dir4 it will print out the file but not change the modified date on dir1 - this will then give me hundreds of files for me to then work out if I can archive the whole of dir1 - is this making any sense?? I want the script to just check the whole of dir1 and all sub dirs (to dir4) and tell me if anything has been modified (-M) within certian ammout of days and just come back with yes files have been modifed with x num of days so cannot archive dir1 then go onto next dir structure.

Many Thanks

Posted by admin (Graham Ellis), 28 June 2006
OK ... I think I'm with it ...

I would modify that same script I posted, but rather than come up with the specific file name that's changed, I would use a split or regular expression on its full path, and increment a hash of counters ...

if (-M $full < 7.0) {
        @parts = split(/\//,$full);

And when you're done, %table will end up with keys for all the top level directories modified ... with a count of the number of items modified in each if that happens to be useful

Posted by hugo_owen (hugo_owen), 29 June 2006
fantastic works a treat.

Many thanks


This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2018: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: • WEB: • SKYPE: wellho