Created
July 31, 2024 01:04
-
-
Save langheran/60d038f034dac6465ff4df12cdd6dd70 to your computer and use it in GitHub Desktop.
C:\Users\NisimHurst\Utilities\Autohotkey\SetFolderTimestampToNewestFile\SetFolderTimestampToNewestFile.ahk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; SetFolderTimestampToNewestFile.ahk | |
; by SanskritFritz | |
; Set a folder's 'modified' date to the timestamp of the newest file it contains. | |
; The folder name should be given as parameter. | |
#NoTrayIcon | |
if 0 <> 1 | |
{ | |
MsgBox The parameter 'folder name' is missing! | |
Return | |
} | |
sFolder = %1% | |
setCurrentFolder(sFolder) | |
Return | |
setCurrentFolder(sFolder){ | |
dTimestamp := "19000101" | |
bThereIsFile := False | |
Loop, Files, %sFolder%\*, FD | |
{ | |
if (InStr(A_LoopFileAttrib, "D")){ | |
setCurrentFolder(A_LoopFileFullPath) | |
} | |
FileGetTime, dFileTime, %A_LoopFileFullPath% | |
if (dTimestamp < dFileTime){ | |
bThereIsFile := True | |
dTimestamp := dFileTime | |
} | |
; if (dTimestamp < A_LoopFileTimeModified) | |
; dTimestamp := A_LoopFileTimeModified | |
} | |
if (bThereIsFile) | |
FileSetTime %dTimestamp%, %sFolder% | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment