Created
March 24, 2018 10:19
-
-
Save altbdoor/6ccc6ff68f4730f36ab9f1a2918f84c8 to your computer and use it in GitHub Desktop.
Inspect and modify modify, creation, accessed date time info for files
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
; compiled exe uploaded at | |
; https://my.mixtape.moe/goitkl.zip | |
#NoEnv | |
#NoTrayIcon | |
#SingleInstance force | |
SetWorkingDir %A_ScriptDir% | |
GUI: | |
SansSerifFont := "Segoe UI" | |
MonospaceFont := "Consolas" | |
Gui, Font, s10, %SansSerifFont% | |
Gui, Add, Text, x10 y10, Please select a file to inspect: | |
Gui, Font, s10, %MonospaceFont% | |
Gui, Add, Edit, w300 h25 x10 y+5 vFilePath, C:\ | |
Gui, Font, s10, %SansSerifFont% | |
Gui, Add, Button, w80 h25 x+0 gBrowseFile Default, Browse | |
Gui, Add, Button, w80 h25 x+0 gLoadFileTime, Refresh | |
Gui, Add, Text, w460 x10 h1 y+10 0x10 | |
Gui, Font, s8, %SansSerifFont% | |
Gui, Add, Text, w460 x10 y+10 Center, Date format is YYYY/MM/DD HH:MM:SS. As an example, 31st December 1984, 2:05:46 PM is described as "1984/12/31 14:05:46". Please stick to this format to eliminate issues. | |
Gui, Font, s10, %SansSerifFont% | |
Gui, Add, Text, x10 y+17, Modified: | |
Gui, Font, s10, %MonospaceFont% | |
Gui, Add, Edit, w150 h25 x100 yp-2 vFileMTime | |
Gui, Font, s10, %SansSerifFont% | |
Gui, Add, Button, w130 h25 x+0 gUseNowMTime, Use Current Time | |
Gui, Add, Button, w90 h25 x+0 gCopyMTime, Copy To All | |
Gui, Add, Text, x10 yp+30, Created: | |
Gui, Font, s10, %MonospaceFont% | |
Gui, Add, Edit, w150 h25 x100 yp-2 vFileCTime | |
Gui, Font, s10, %SansSerifFont% | |
Gui, Add, Button, w130 h25 x+0 gUseNowCTime, Use Current Time | |
Gui, Add, Button, w90 h25 x+0 gCopyCTime, Copy To All | |
Gui, Add, Text, x10 yp+30, Accessed: | |
Gui, Font, s10, %MonospaceFont% | |
Gui, Add, Edit, w150 h25 x100 yp-2 vFileATime | |
Gui, Font, s10, %SansSerifFont% | |
Gui, Add, Button, w130 h25 x+0 gUseNowATime, Use Current Time | |
Gui, Add, Button, w90 h25 x+0 gCopyATime, Copy To All | |
Gui, Add, Text, w460 x10 h1 y+10 0x10 | |
Gui, Add, Button, Center w160 h30 x150 y+10 gSaveFileTime, Save File Time Info | |
Gui, Show, Center w480, AHK Filetime | |
Return | |
BrowseFile: | |
FileSelectFile, SelectFilePath, , C:\, Please select the file | |
If (SelectFilePath != "") { | |
GuiControl, , FilePath, %SelectFilePath% | |
Gosub, LoadFileTime | |
} | |
Return | |
LoadFileTime: | |
Gui, Submit, NoHide | |
If (!FileExist(FilePath)) { | |
MsgBox, 0x30, Error, The file does not exist! | |
} | |
Else { | |
FileGetTime, FileRawMTime, %FilePath%, M | |
FileGetTime, FileRawCTime, %FilePath%, C | |
FileGetTime, FileRawATime, %FilePath%, A | |
GuiControl, , FileMTime, % ParseDateRawToHuman(FileRawMTime) | |
GuiControl, , FileCTime, % ParseDateRawToHuman(FileRawCTime) | |
GuiControl, , FileATime, % ParseDateRawToHuman(FileRawATime) | |
} | |
Return | |
CopyMTime: | |
Gui, Submit, NoHide | |
GuiControl, , FileCTime, %FileMTime% | |
GuiControl, , FileATime, %FileMTime% | |
Return | |
CopyCTime: | |
Gui, Submit, NoHide | |
GuiControl, , FileMTime, %FileCTime% | |
GuiControl, , FileATime, %FileCTime% | |
Return | |
CopyATime: | |
Gui, Submit, NoHide | |
GuiControl, , FileMTime, %FileATime% | |
GuiControl, , FileCTime, %FileATime% | |
Return | |
UseNowMTime: | |
Gui, Submit, NoHide | |
GuiControl, , FileMTime, % ParseDateRawToHuman(A_Now) | |
Return | |
UseNowCTime: | |
Gui, Submit, NoHide | |
GuiControl, , FileCTime, % ParseDateRawToHuman(A_Now) | |
Return | |
UseNowATime: | |
Gui, Submit, NoHide | |
GuiControl, , FileATime, % ParseDateRawToHuman(A_Now) | |
Return | |
ParseDateRawToHuman(DateRaw) { | |
DateHuman := "" | |
If (DateRaw != "") { | |
FormatTime, DateHuman, %DateRaw%, yyyy/MM/dd HH:mm:ss | |
} | |
Return DateHuman | |
} | |
ParseDateHumanToRaw(DateHuman) { | |
DateRaw := "" | |
If (RegexMatch(DateHuman, "^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}$")) { | |
DateRaw := RegExReplace(DateHuman, "[^\d]", "") | |
If (StrLen(DateRaw) != 14) { | |
DateRaw := "" | |
} | |
} | |
Return DateRaw | |
} | |
SaveFileTime: | |
Gui, Submit, NoHide | |
FileNewMTime := ParseDateHumanToRaw(FileMTime) | |
FileNewCTime := ParseDateHumanToRaw(FileCTime) | |
FileNewATime := ParseDateHumanToRaw(FileATime) | |
ErrorMsg := "" | |
If (FileNewMTime == "") { | |
ErrorMsg := "<!> Invalid input for File Modified Time `n" . ErrorMsg | |
} | |
If (FileNewCTime == "") { | |
ErrorMsg := "<!> Invalid input for File Created Time `n" . ErrorMsg | |
} | |
If (FileNewATime == "") { | |
ErrorMsg := "<!> Invalid input for File Accessed Time `n" . ErrorMsg | |
} | |
If (ErrorMsg == "") { | |
FileSetTime, %FileNewMTime%, %FilePath%, M | |
FileSetTime, %FileNewCTime%, %FilePath%, C | |
FileSetTime, %FileNewATime%, %FilePath%, A | |
} | |
Else { | |
MsgBox, 0x30, Error, %ErrorMsg% | |
} | |
Return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment