Welcome Guest.   Make a donation to an author on the site October 22, 2014, 11:32:13 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2010! Download 24 custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: IDEA: set folder modifed date/time to most recently modified file it contains  (Read 7061 times)
fhayes
Charter Member
***
Posts: 18


see users location on a map View Profile Give some DonationCredits to this forum member
« on: January 02, 2009, 02:24:51 PM »

When trying to keep directory trees in sync between local disks and network drives, it is confusing when some of the folder dates get changed by the move/copy operation. FileSync tools may ignore this but unfortunately my brain does not.
When looking at the source and destination directories I'd like the folder 'modified' date/time to reflect the most recently 'modified' file within that folder (tree). If the folder contains subfolders then it would be nice if it walked down the directory tree recursively modifying subdirectory timestamps and taking care of the entire tree. (Only the 'modified' timestamp would be altered)
Logged
f0dder
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: January 02, 2009, 05:06:20 PM »

So, you want each folder modified-timestamp to be the timestamp of the most recently modified file just in that folder, or in the entire sub-folder tree?
Logged

- carpe noctem
fhayes
Charter Member
***
Posts: 18


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #2 on: January 02, 2009, 06:57:21 PM »

probably would be best to timestamp check just the files within the folder being viewed. Then when trying to figure out whats different across two dir trees you would know that if the folder dates differ, that the files that differ are at the next level down. This algorithm would then recurse down any discovered subdirectories checking their times to the times of the files found within them. Basically "fixing" the "broken" dates on the entire folder tree.
Logged
mouser
First Author
Administrator
*****
Posts: 33,578



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #3 on: January 27, 2009, 10:36:47 AM »

this would be useful.
Logged
Crush
Member
**
Posts: 399



Hello dude!

see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #4 on: January 27, 2009, 11:46:07 AM »

I have some files here that contain NO kind of timestamp. This would be useful to repair these broken dates. Does someone also has found anything like this on his drives?
Logged
kwacky1
Supporting Member
**
Posts: 178



i am Cody's cousin

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #5 on: January 28, 2009, 04:01:01 AM »

I have some files here that contain NO kind of timestamp. This would be useful to repair these broken dates. Does someone also has found anything like this on his drives?

Crush, you might find AnteDator useful for that purpose.
Logged

f0dder
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #6 on: January 29, 2009, 08:12:55 AM »

Crush: no timestamp? That sounds pretty messed up and basically impossible :-s
Logged

- carpe noctem
kwacky1
Supporting Member
**
Posts: 178



i am Cody's cousin

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #7 on: January 30, 2009, 08:18:56 AM »

Crush: no timestamp? That sounds pretty messed up and basically impossible :-s

f0dder, not impossible with the above mention product  Wink
Logged

lanux128
Global Moderator
*****
Posts: 6,109



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #8 on: January 31, 2009, 12:49:58 AM »

maybe this tool can fix the problem - Ninotech Date Edit.

Quote
"Ninotech Date Edit is a shell extension for Windows that enables you to change the date and time (the timestamp) of your files. You can change the created, modified, and accessed date of a file by right-clicking it in the Windows Explorer and choosing Edit Date from the context menu. By selecting multiple files in the Windows Explorer you are allowed to change the date/time of many files in just one action.

On Windows NT4, Windows 2000, and Windows XP you are also enabled to change the time and date of your directories."

http://home.worldonline.dk/ninotech/

PS. the website is not working currently.
Logged

skrommel
Fastest code in the west
Developer
***
Posts: 882



View Profile WWW Give some DonationCredits to this forum member
« Reply #9 on: January 31, 2009, 06:11:01 AM »

 smiley Try MostRecent!

Select the start folder, and it will recurse the folder and set it's and all it's subfolders' modifed date/time to the most recently modified file or folder it contains.

Skrommel

[copy or print]
;MostRecent.ahk
; Set folder modifed date/time to most recently modified file it contains.
; To run, save this script as MostRecent.ahk, and install AutoHotkey from www.autohotkey.com.
;Skrommel @ 2009

#NoEnv
#SingleInstance,Force

FileSelectFolder,folder,C:\,3,Select a folder to change the date/time of
TRAVERSE(folder)
Return


TRAVERSE(folder)
{
  mostrecent=0
  Loop,%folder%\*.*,1,0
  {
    IfInString,A_LoopFileAttrib,D
      childrecent:=TRAVERSE(A_LoopFileLongPath)
    If (childrecent>mostrecent)
      mostrecent:=childrecent
    If (A_LoopFileTimeModified>mostrecent)
      mostrecent:=A_LoopFileTimeModified
  }
  MsgBox,%mostrecent%`n%folder%
  FileSetTime,%mostrecent%,%folder%,M,2,0
  Return,%mostrecent%
}
« Last Edit: January 31, 2009, 06:13:27 AM by skrommel » Logged

Please stop by my site at  1 Hour Software by skrommel  for downloads and more info.
fhayes
Charter Member
***
Posts: 18


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #10 on: March 06, 2009, 12:43:26 AM »

Thank you Skrommel, that's excellent. That loop is a bit tricky, I definitely wouldn't have been able to come up with it. I forgot about this ask till tonight and was excited to see your solution posted here when I arrived back at this thread. It also got me back looking into AHK scripting, I've really got to find the time to get into this more, it's such a great tool. I made a few tweaks and added an output listing and repost it here. Thanks again!
[copy or print]
; 1/31/09 authored by Skrommel www.donationcoder.com/Software/Skrommel (Very Nice, Thank You!)
; 3/06/09 fhayes
;         build and display list of changed dirs when program completes
;         improved error handling

;MostRecent.ahk
; Set folder modifed date/time to most recently modified file it contains.
; user selects the top of the folder tree to be processed
; only files in the immediate folder being processed effect that folders timestamp decision
; all subfolder in the tree are processed as well
; To run, save this script as MostRecent.ahk, and install AutoHotkey from www.autohotkey.com.
;Skrommel @ 2009

#NoEnv
#SingleInstance,Force

FileSelectFolder,folder,*C:\,3,Select a folder to change the date/time of
if ErrorLevel
  MsgBox,,,No folder selected,1
else
  {
  changelist := TRAVERSE(folder)
  header = ** press Control-C to copy this text to the clipboard **`n`n
  MsgBox,,List of updated directory timestamps,%header%%changelist%
  }
Return

TRAVERSE(folder)
{
  static filelist = ""
  mostrecent=0
  Loop,%folder%\*.*,1,0               ;include all files and folders, no recursion
  {
    IfInString,A_LoopFileAttrib,D             ;is this a directory
      childrecent:=TRAVERSE(A_LoopFileLongPath)
    If (childrecent>mostrecent)
      mostrecent:=childrecent
    If (A_LoopFileTimeModified>mostrecent)
      mostrecent:=A_LoopFileTimeModified
  }
  FileSetTime,%mostrecent%,%folder%,M,2,0 ;time modified,only folders,no recursion
  FormatTime, TimeString, %mostrecent%, MM/dd/yyyy hh:mm tt
  If (mostrecent<>0)                      ;if dir is not empty
    filelist = %filelist%%TimeString%`t%folder%`n  ;add to list
  Return (filelist)
}
Logged
FredThompson
Participant
*
Posts: 3

View Profile Give some DonationCredits to this forum member
« Reply #11 on: July 30, 2011, 11:05:45 PM »

This script seems to have a relatively low limit to the number of files which it will scan. The whole routine stops after about 1,000 files are checked. Is there a limit in AutoHotKey?
Logged
MilesAhead
Member
**
Posts: 4,941



View Profile WWW Give some DonationCredits to this forum member
« Reply #12 on: August 04, 2011, 04:33:22 PM »

If your folder chain time stamp situation doesn't need repair and you just want to sync folders with subfolders, I've found the sync tool in FreeCommander very simple to use in 2 base folder sync scenario. What I mean is you don't have to sync one source folder with 20 destination folders.  You have a folder on the left and one on the right. Sync with or without recursive subfolder sync.  Before you commit it shows a window with a display of which files will be copied in which direction and allows you to remove items from the list.

edit: although if you have thousands of files it may be cumbersome.  Works well for my needs.
Logged

"Genius is not knowing you can't do it that way."
- MilesAhead
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.038s | Server load: 0.16 ]