DonationCoder.com Software > Post New Requests Here
IDEA: set folder modifed date/time to most recently modified file it contains
fhayes:
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!
--- ---; 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)
}
FredThompson:
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?
MilesAhead:
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.
Navigation
[0] Message Index
[*] Previous page
Go to full version