[func] Touch() - set, store and restore file datetime stamp

Post your working scripts, libraries and tools for AHK v1.1 and older
ahk7
Posts: 575
Joined: 06 Nov 2013, 16:35

[func] Touch() - set, store and restore file datetime stamp

Post by ahk7 » 07 Nov 2013, 14:48

A function to set, store and restore the datetime stamp of a file or folder. Useful when you are modifying files and you want to keep the original datetime stamp. The datetime stamp properties are stored in a static object.

Function and documentation at https://github.com/hi5/Touch

Example:

Code: Select all

; Touch(file = "" [, set = "0", WhichTime = "M", Reference = "0"] )
MsgBox % Touch("file.txt",1) ; store datetime stap
MsgBox % Touch("file.txt") ; update to current date & time, a shorthand for FileSetTime
MsgBox % "file.txt should be the newest file in the directory."
MsgBox % Touch("file.txt",2) ; restore old datetime stamp
Touch() ; free memory

Return to “Scripts and Functions (v1)”