Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

FOR WINDOWS:

I need to change the TOP FOLDER timestamp to reflect the latest file or the latest sub-folder added. Note, I do not want to change the sub-folder's timestamp properties in which no newer files are added. So, only the sub-folder and TOP Folder need to have timestamp attributes changed matching to the NEWEST most file (or sub-folder) allowing for empty folder and zero-byte file (e.g. '.').

If this can be scripted PREFERENTIALLY in WSH, VB, Powershell or Ms-DOS (python, PERL, etc..)batch file so that I can run it in a Task Scheduler to automate the process (at the end of the day, say 8pm).

I have seen similar questions for *NUX but no conclusive answer for *NUX or Windows (and Mac). This must be a real challenge. Since I have very little knwoledge in Widows APIs (or for that matter in programming of any kind), I need SuperUser crowd help. Thanks, Thanks...

Suggestion: using MD5 hashes to compare filetime stamp (does it make sense?)

for example see: http://msdn.microsoft.com/en-us/library/ms724205%28v=vs.85%29 http://msdn.microsoft.com/en-us/library/ms724284%28VS.85%29.aspx

share|improve this question
1  
By TOP FOLDER do you mean the filesystem root directory? If so then it seems to me the root directory's timestamp is just going to be constantly updated and its value won't tell you much... –  Celada Aug 11 '12 at 15:37
    
I think he means every parent directory of a file that was changed. Why would you want that? –  wullxz Aug 11 '12 at 16:14
    
You've indicated in the tags and title that you'd like a solution for unix, but your question implies you only want a solution for windows. Can you clarify please? Also, if I understand you correctly, any possible solution is going to be very slow as it will have to walk the entire directory structure to see if any file within has been modified. In Linux it may be possible to do something with inotify. –  grifferz Aug 11 '12 at 23:03
    
grifferz, I prefer solution script for Windows XP/V/7 because I need the solution for my WindowsXP PC. It is rather synonymous with torutur by CUT|COPY /PASTE since so much data needs to be transferred. Since this is a dynamic situation where the data stream continually comes in (for example, say you are taking snapshot every 30sec in webcam looking at street. Each time a snapshot is taken it enters into directory-last image with file name including timestamp.)At end of week all data is moved up into another directory so as to keep directory-last less than 256 files) –  C2940680 Aug 17 '12 at 17:45
    
(continued...) If I can have VBS, it would be ideal. Alternate script mechanisms are less desirable, not unwanted). I put Linux/Unix just so that other people in that world can benefit also. Thanks for your comments. –  C2940680 Aug 17 '12 at 17:48
add comment

1 Answer

It is written in bash / cygwin, and works for what I needed it for - which sounds similar to your needs... It is not efficient by any means, but it is effective.

=================

find -maxdepth 1 -type d | grep -v "^\.$" | while read D ; do
 cd "$D"
 F=`ls -1tr | tail -1`
 cd ..
 touch -r "$D/$F" "$D"
done

=================

Brian

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.