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
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho