Sign in to follow this  
Followers 0
meows

Is there a issue With filesettime/filegettime and win7 fileproperties time? all are different

6 posts in this topic

#1 ·  Posted (edited)

no web server atm. so the win7 file properties images I can't show you but they are totally different from the variables I am getting..But then I am just guesstamating the code needed from any and all sources i can find to just get the Minutes difference between 2 files.

I can touch the files to change anything, but can't get the value to use it and using FilesetTime/ only works with the Help code. and it is way over my head. I have searched the web looking for a step by step but it's all in arrays that array me.

The FileSetTime

;Modified help file
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
$sFilePath=("C:\file1.txt")
Local $iFileSetTime = FileSetTime($sFilePath, "20031101121101"  )

    ; Display the modified timestamp of the file and return as a string in the format YYYYMMDDHHMMSS.
    If $iFileSetTime Then
       ; MsgBox($MB_SYSTEMMODAL, "", "Timestamp:" & @CRLF & FileGetTime($sFilePath, $FT_ACCESSED, 2  ))  RETURNS Timestamp:
    ;   MsgBox($MB_SYSTEMMODAL, "", "Timestamp:" & @CRLF & FileGetTime($sFilePath, 2  ))                  RETURNS Timestamp:
      ; MsgBox($MB_SYSTEMMODAL, "", "Timestamp:" & @CRLF & FileGetTime($sFilePath, "YYYYMMDDHHMMSS"  ))  RETURNS Timestamp:
      ; MsgBox($MB_SYSTEMMODAL, "", "Timestamp:" & @CRLF & FileGetTime($sFilePath, $FT_MODIFIED, 1))       RETURNS Timestamp:
      The only one that returns Anything is the last one and it returns the whole string..Timestamp:20031101121101  ; RETURNS  Timestamp:20031101121101
     File Properties accessed time and date ?Saturday, ?November ?01, ?2003, ??1:01:00 AM File

EndIf

changed created date but displays YYYYMMDDHHMMSS"

So I got creative and after /////..... and more of that got this to work.. "Kinda"

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=TimeCK.exe
#AutoIt3Wrapper_Res_Fileversion=21
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include<File.au3>
#include <FileConstants.au3>
#include <Constants.au3>
#include <MsgBoxConstants.au3>
#Include <Date.au3>
;change file.au3's "modified" timestamp to 1st Nov 2003 and current time
;Local $var = FileSetTime("file.au3", "20031101")
;Local $iFileSetTime = FileSetTime($sFilePath, "20031101", $FT_MODIFIED)
;Local $iFileSetTime = FileSetTime("c:\2a.jpg", "20031101", 1)
;change file.au3's "modified" timestamp to 1st Nov 2003 and current time
;Local $v = FileSetTime(@ScriptDir &"\00\2a.jpg", "20031101", 1)
Local $v = FileSetTime(@ScriptDir &"\00\2a.jpg", "2003110120031101121101", 1)
If Not @error Then
   ; Local $HHMMSS =  $v[0] & "/" &  $v[1] & "/" &  $v[2]
     Local $MMss =  ($v )
    MsgBox(0, "Creation date of 2a", $MMss)
EndIf

Local $t = FileGetTime(@ScriptDir & "\00\Files\core\2a.jpg", 1)

;HH:MM:SS
If Not @error Then
;      Local $hhmms = $t[0] & "/" & $t[1] & "/" & $t[2]
    Local $mm = $t[1]
    MsgBox(0, "time change", $mm)

;Local $t = FileGetTime("c:\2a.jpg", 1)

;HH:MM:SS
;If Not @error Then
;      Local $hhmms = $t[0] & "/" & $t[1] & "/" & $t[2]
 ;   Local $mm = $t[2]
  ;  MsgBox(0, "Creation date of notepad.exe", $mm)
EndIf

The issue is it gives 3 totally different times for the Minute.. I only want the minute difference.

the "Creation date of 2a" tag gives a 0 minute value==and in 3 hours now it still gives the 0 minute value

the "time change" tag gives a 28 minute value ==== and in 3 hours now it still gives the 28 minute value

Win7 "File Properties" tag gives

?Sunday, ?June ?22, ?2014, ??1:11:42 PM   ------------FileSetTime(@ScriptDir &"002a.jpg", "2003110120031101121101", 1)
Saturday, ?June ?28, ?2014, ??3:05:36 PM
Sunday, ?June ?22, ?2014, ??1:11:42 PM



Saturday, ?November ?01, ?2003, ??7:03:11 PM --------------------FileGetTime(@ScriptDir & "00Filescore2a.jpg", 1)
Saturday, ?June ?28, ?2014, ??3:05:36 PM
?Today, ?June ?30, ?2014, ??5 minutes ago   
 

U know I think I learned more in the two hours it took to write this very bad dissertation of the issue. Researching everything I wanted to say and try to explain the steps took to get the results.

Edited by meows

Share this post


Link to post
Share on other sites



meows,

The issue is with you using incorrect parameters in the function calls: ;)

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>

$sFilePath=("Test.txt")

Local $iFileSetTime = FileSetTime($sFilePath, "20031101121101")

; Display the modified timestamp of the file and return as a string in the format YYYYMMDDHHMMSS.
If $iFileSetTime Then

    ; What is format 2?  Only 0 & 1 are defined in the Help file
    MsgBox($MB_SYSTEMMODAL, "Incorrect format", "Timestamp:" & @CRLF & FileGetTime($sFilePath, $FT_ACCESSED, 2))
    MsgBox($MB_SYSTEMMODAL, "Correct format Modified", "Timestamp:" & @CRLF & FileGetTime($sFilePath, $FT_MODIFIED , 1))  ; Returns timestamp as set above

    ; MsgBoxes cannot display arrays
    MsgBox($MB_SYSTEMMODAL, "Accessed", "Timestamp:" & @CRLF & FileGetTime($sFilePath, 2)) ; By not using a format parameter you are asking for an array to be returned...
    _ArrayDisplay(FileGetTime($sFilePath, 2), "Accessed", Default, 8) ; ...and here it is
        
    ; What option is YYYYMMDDHHMMSS?  You can only use the constants as defined in the Help file
    MsgBox($MB_SYSTEMMODAL, "WTF?", "Timestamp:" & @CRLF & FileGetTime($sFilePath, "YYYYMMDDHHMMSS"))

    ; Hurrah - some correct syntax!
    MsgBox($MB_SYSTEMMODAL, "", "Timestamp:" & @CRLF & FileGetTime($sFilePath, $FT_MODIFIED, 1))  ; Of course this works - it is the only one with a correct syntax

EndIf
The modified lines work perfectly for me - do they for you? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I do not know what I did wrong,, but I got

I did make a test.txt in the same dir as the script.. but maybe it needs to be somewhere else?

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Program Files\AutoIt3\SonoMini\modifiedTime.au3" /UserParams    
+>03:14:59 Starting AutoIt3Wrapper v.2.1.4.5 SciTE v.3.3.7.0   Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X86    Environment(Language:0409)
>Running AU3Check (3.3.10.2)  from:C:\Program Files\AutoIt3  input:C:\Program Files\AutoIt3\SonoMini\modifiedTime.au3
"C:\Program Files\AutoIt3\SonoMini\modifiedTime.au3"(18,69) : error: _ArrayDisplay() called with expression on Const ByRef-param(s).
    _ArrayDisplay(FileGetTime($sFilePath, 2), "Accessed", Default, 8)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Program Files\AutoIt3\Include\Array.au3"(188,224) : REF: definition of _ArrayDisplay().
Func _ArrayDisplay(Const ByRef $avArray, $sTitle = Default, $sArray_Range = Default, $iFlags = Default, $vUser_Separator = Default, $sHeader = Default, $iMax_ColWidth = Default, $iAlt_Color = Default, $hUser_Func = Default)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Program Files\AutoIt3\SonoMini\modifiedTime.au3 - 1 error(s), 0 warning(s)
!>03:14:59 AU3Check ended. Press F4 to jump to next error.rc:2
+>03:15:00 AutoIt3Wrapper Finished..
>Exit code: 2    Time: 0.725

I did copy it right I think..

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>

$sFilePath=("Test.txt")

Local $iFileSetTime = FileSetTime($sFilePath, "20031101121101")

; Display the modified timestamp of the file and return as a string in the format YYYYMMDDHHMMSS.
If $iFileSetTime Then

    ; What is format 2?  Only 0 & 1 are defined in the Help file
    MsgBox($MB_SYSTEMMODAL, "Incorrect format", "Timestamp:" & @CRLF & FileGetTime($sFilePath, $FT_ACCESSED, 2))
    MsgBox($MB_SYSTEMMODAL, "Correct format Modified", "Timestamp:" & @CRLF & FileGetTime($sFilePath, $FT_MODIFIED , 1))  ; Returns timestamp as set above

    ; MsgBoxes cannot display arrays
    MsgBox($MB_SYSTEMMODAL, "Accessed", "Timestamp:" & @CRLF & FileGetTime($sFilePath, 2)) ; By not using a format parameter you are asking for an array to be returned...
    _ArrayDisplay(FileGetTime($sFilePath, 2), "Accessed", Default, 8) ; ...and here it is

    ; What option is YYYYMMDDHHMMSS?  You can only use the constants as defined in the Help file
    MsgBox($MB_SYSTEMMODAL, "WTF?", "Timestamp:" & @CRLF & FileGetTime($sFilePath, "YYYYMMDDHHMMSS"))

    ; Hurrah - some correct syntax!
    MsgBox($MB_SYSTEMMODAL, "", "Timestamp:" & @CRLF & FileGetTime($sFilePath, $FT_MODIFIED, 1))  ; Of course this works - it is the only one with a correct syntax

EndIf

Share this post


Link to post
Share on other sites

meows,

It is because you are still using v3.3.10.2 and the _ArrayDisplay code has been rewritten since then. Change it to read:

$aTime = FileGetTime($sFilePath, 2)
_ArrayDisplay($aTime, "Accessed", Default, 8)
That should be working now. :)

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

meows,

It is because you are still using v3.3.10.2 and the _ArrayDisplay code has been rewritten since then. Change it to read:

$aTime = FileGetTime($sFilePath, 2)
_ArrayDisplay($aTime, "Accessed", Default, 8)
That should be working now. :)

M23

 

It is indeed working..

Thank you very much for the lesson. It really helps to understand why it works and doesn't work, Off and running now! :)

Share this post


Link to post
Share on other sites

meows,

Delighted to hear it. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • AutoitMike
      By AutoitMike
      I saw a post dated 2013 about WinSetTitle not working in Win7 64bit. No answer there for me.
      I am trying to set the title of a window, the function returns success and the title is changed for about 50 ms and then reverts back to its original value.
      #RequireAdmin makes no difference in operation.
      I have tried using the handle, the title and the class to define the window. Operation is the same for all three ways.
      EG:
      WinSetTitle("Old Title", "", "New Title")
      WinSetTitle("[Class:Class name]","","New Title")
      WinSetTitle(handle,"","New Title")
      ;=======================================================================================
      All functions report success.
      WinActivate("PxxCXpbHG", "Text")
      WinSetTitle("PxxCXpbHG ", "Text","New title")
      $M1=WinGetTitle("[ACTIVE]","")
      sleep (100)
      $M2=WinGetTitle("[ACTIVE]","")
      MsgBox(0,"", $M1 & "  " & $M2) ;------------------> "New Title"  "PxxCXpbHG"
      If I change Sleep to 50 , then it is "New Title", "New Title" so somewhere between 50 and 100 ms it gets changed back,but by what??
      Thanks for any help in this matter.
       
       
       
       
    • imitto
      By imitto
      Hello all!
      I was in read-only until today, started to use Autoit 3 weeks ago. It can really make things easy, I really love it
      I have some script now that works and make our job effective, but I have problems with the latest. It works if I open the script's folder and run the exe directly. If I use the shortcut that I created on the desktop, it's not working properly. Activates the window, but not opening/exporting my files, just opens the last msgbox. I use ftp becouse the PC and the destination PC is not on the same network.
      Here's the script:
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\microsoft_excel.ico #AutoIt3Wrapper_Res_Comment=send file over ftp #AutoIt3Wrapper_Res_Description=send file over ftp for process #AutoIt3Wrapper_Res_Language=1038 #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: imitto Script Function: Rename and put playlist file on ftp #ce ---------------------------------------------------------------------------- #RequireAdmin #include <File.au3> #include <FileConstants.au3> #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include <FTPEx.au3> ; Script Start Global $playlistname=@YEAR&@MON&@MDAY&"-playlist.pll" BlockInput($BI_DISABLE) Opt ("WinTitleMatchMode", 2) WinActivate("MAIN SCHED") WinWaitActive("MAIN SCHED") ;Opt ("WinTitleMatchMode", 1) Send("!fo") WinWaitActive("Open") Send("Z:\playlist\"&$playlistname&"{ENTER}") Sleep(2000) Send("!fe") WinWaitActive("MCon") Send("{ENTER}") WinWaitActive("Save") Send("C:\sendFileForXLS\lista.txt{ENTER}") Sleep(500) Send("!fc") BlockInput($BI_ENABLE) Sleep(50) Opt ("WinTitleMatchMode", 1) Local $hOpen = _FTP_Open('MyFTP Control') $ftp=_FTP_Connect($hOpen, "**********", "******", "******") If @error Then MsgBox($MB_SYSTEMMODAL, '_FTP_Connect', 'ERROR=' & @error) Else _FTP_FilePut($ftp, @ScriptDir&"\lista.txt", "/lista.txt") EndIf Local $iFtpc = _FTP_Close($hOpen) FileDelete(@ScriptDir&"\lista.txt") MsgBox(0, "", "Playlist exported", 2) Exit  
    • hifi55
      By hifi55
      Enabling DST (the summertime and wintertime schedules across the globe) within your time zone might cause an unexpected shift in datetimes by 1 hour when you're trying to set filetimes with FileSetTime or read them with FileGetTime. This behaviour frequently causes bugreports like #3139 at https://www.autoitscript.com/trac/autoit/ticket/3139 'FileGetTime out by exactly one hour.', where it was classified as 'No bug'.
      Now this isn't considered a bug when you're referring to the datetime as shown by the command prompt (DOS prompt, even in Windows 7+) or Windows Explorer XP, as these programs use 'old style' DST behaviour. But it definitely can be considered a bug when you're using Windows Explorer 7+, which adopts the 'new style' behaviour.
      'Old style' (currently implemented, v3.3.14.2 and previous) calculates datetimes as follows:
          FileSetTime = local time    - time zone - DST currently in effect
          FileGetTime = file datetime + time zone + DST currently in effect
          
      whereas 'new style' calculation of datetimes would require:
          FileSetTime = local time    - time zone - DST in effect at the time of the file's datetime (Dynamic Time Zones)
          FileGetTime = file datetime + time zone + DST in effect at the time of the file's datetime (Dynamic Time Zones)
      This 'new style' behaviour will leave your timestamps unaltered in Windows Explorer 7+ whenever a transition to summertime or wintertime occurs, but requires detailed records of all DST schedules worldwide. Fortunately all these records are readily available in Windows 7+! You can read more about this in Raymond Chen insider blogs at https://blogs.msdn.microsoft.com/oldnewthing/20130308-00/?p=5023 and https://technet.microsoft.com/en-us/magazine/ff394358.aspx
      To have FileSetFile and FileGetFile adopt the 'new style' DST behaviour, I've written FileSetFileExt and FileGetFileExt.
      As part of FileSetFileExt, which has an option to recurse into the given path, the function FindFiles was created. It's included separately and you can easily apply it as a stand-alone function to recurse a given path and process all files that match a specified pattern. I think it's a useful function that AutoIt unfortunately still lacks.
      FileSetTimeExt (FileSetTime voor DST en Win7+):
      #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include <File.au3> #include <Date.au3> #include <WinAPIFiles.au3> #include <WinAPI.au3> ConsoleWrite("Set Modified datetime of this script to Jan 12th 2016 at 15:16:17" & @CRLF) FileSetTimeExt(@ScriptFullPath, "20160123151617", 0, 0) Func FileSetTimeExt($filename, $time, $type = 0, $recurse = 0) ; v1.0 ; Extended FileSetTime function to properly deal with DST (Daylight Saving Time (summertime/wintertime)) on Windows 7+ ; Usage is identical to the FileSetTime function with full wildcard support, including multiple * and ? usage. ; ; AutoIt Version: 3.3.14.2 ; This function requires Windows 7 or later. ; ; Requirements to include in your main program: ; #include <File.au3> ; #include <Date.au3> ; #include <WinAPIFiles.au3> ; #include <WinAPI.au3> If $type = Default Then $type = 0 If $recurse = Default Then $recurse = 0 If $time = "" Then $time = StringRegExpReplace(_NowCalc(), "[^0-9]", "") Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "", $ssDir = "", $sDummy1 = "", $sDummy2 = "" _PathSplit($filename, $sDrive, $sDir, $sFileName, $sExtension) ; extend path to full path if filename has no path or a path relative to ScriptDir If $sDrive = "" Then _PathSplit(@ScriptFullPath, $sDrive, $ssDir, $sDummy1, $sDummy2) $sDir = $ssDir & $sDir $filename = _PathMake($sDrive, $sDir, $sFileName, $sExtension) EndIf ; FileSetTime makes no difference between * and *.*, whereas_WinAPI_IsNameInExpression does, so make adjustments If $sExtension = ".*" Then $sFileName = $sFileName & "*" $sExtension = "" EndIf Local $hSearch $hSearch = FileFindFirstFile(_PathMake($sDrive, $sDir, "*", ".*")) ; searches for every file and directory If $hSearch = -1 Then Return 1 Local $pattern, $eExt, $tSystem, $tFile, $hFile, $pFileName ; get correct local time $tSystem = _Date_Time_EncodeSystemTime(StringMid($time, 5, 2), StringMid($time, 7, 2), StringLeft($time, 4), _ StringMid($time, 9, 2), StringMid($time, 11, 2), StringMid($time, 13, 2)) $tSystem = _Date_Time_TzSpecificLocalTimeToSystemTime($tSystem) $tFile = _Date_Time_SystemTimeToFileTime($tSystem) $pattern = StringMid(_PathMake("", "", $sFileName, $sExtension), 2) ; StringMid skips leading \ While 1 $sFileName = FileFindNextFile($hSearch) If @error = 1 Then ; no more files or directories match the pattern ExitLoop Else $eExt = @extended $pFileName = _PathMake($sDrive, $sDir, $sFileName, "") ; _WinAPI_IsNameInExpression supports full wildcard matching, including multiple * and ? usage. If _WinAPI_IsNameInExpression($sFileName, $pattern) Then ; set correct local time for matching file or directory ; try the usual function first to catch errors beforehand If FileSetTime($pFileName, $time, $type) = 0 Then FileClose($hSearch) Return 0 ; abort on error EndIf ; use _WinAPI_CreateFileEx instead of _WinAPI_CreateFile to include directory renaming without an 'Access is denied' error $hFile = _WinAPI_CreateFileEx($pFileName, $OPEN_EXISTING, $GENERIC_WRITE, $FILE_SHARE_WRITE, $FILE_FLAG_BACKUP_SEMANTICS) Switch $type Case 0 _Date_Time_SetFileTime($hFile, 0, 0, $tFile) ; set time Last modified (= Last written) (default) Case 1 _Date_Time_SetFileTime($hFile, $tFile, 0, 0) ; set time Created Case 2 _Date_Time_SetFileTime($hFile, 0, $tFile, 0) ; set time Last accessed EndSwitch _WinAPI_CloseHandle($hFile) EndIf ; perform a full recursive search if need be If $eExt = 1 And $recurse = 1 Then If FileSetTimeExt($pFileName & '\' & $pattern, $time, $type, $recurse) = 0 Then FileClose($hSearch) Return 0 ; abort on error EndIf EndIf EndIf WEnd FileClose($hSearch) Return 1 ; no error occurred EndFunc ;==>FileSetTimeExt FileGetTimeExt (FileGetTime voor DST en Win7+):
      #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include <File.au3> #include <Date.au3> #include <WinAPIFiles.au3> #include <WinAPI.au3> ConsoleWrite("Modified datetime of this script is " & FileGetTimeExt(@ScriptFullPath, 0, 1) & @CRLF) ConsoleWrite("Created datetime of this script is " & FileGetTimeExt(@ScriptFullPath, 1, 1) & @CRLF) ConsoleWrite("Last accessed datetime of this script is " & FileGetTimeExt(@ScriptFullPath, 2, 1) & @CRLF) Func FileGetTimeExt($filename, $option = 0, $format = 0) ; v1.0 ; Extended FileGetTime function to properly deal with DST (Daylight Saving Time (summertime/wintertime)) on Windows 7+ ; Usage is identical to the FileGetTime. ; ; AutoIt Version: 3.3.14.2 ; This function requires Windows 7 or later. ; ; Requirements to include in your main program: ; #include <File.au3> ; #include <Date.au3> ; #include <WinAPIFiles.au3> ; #include <WinAPI.au3> If $option = Default Then $option = 0 If $format = Default Then $format = 0 Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "", $ssDir = "", $sDummy1 = "", $sDummy2 = "" _PathSplit($filename, $sDrive, $sDir, $sFileName, $sExtension) ; extend path to full path if filename has no path or a path relative to ScriptDir If $sDrive = "" Then _PathSplit(@ScriptFullPath, $sDrive, $ssDir, $sDummy1, $sDummy2) $sDir = $ssDir & $sDir $filename = _PathMake($sDrive, $sDir, $sFileName, $sExtension) EndIf Local $aTime, $tDate, $tOut[6], $hFile, $tSystem, $tLocal, $tFile FileGetTime($filename, $option, $format) ; test if no error occurs If @error Then Return SetError(@error, 0, "") ; use _WinAPI_CreateFileEx instead of _WinAPI_CreateFile to include directory access without an 'Access is denied' error $hFile = _WinAPI_CreateFileEx($filename, $OPEN_EXISTING, $GENERIC_READ, $FILE_SHARE_READ, $FILE_FLAG_BACKUP_SEMANTICS) Switch $option ; convert FileGetTime option 0 to _Date_Time_GetFileTime option 2, 1 to 0 and 2 to 1 Case 0 $option = 2 ; Last modified (default) Case 1 $option = 0 ; Created Case 2 $option = 1 ; Last accessed EndSwitch $aTime = _Date_Time_GetFileTime($hFile) _WinAPI_CloseHandle($hFile) $aTime = $aTime[$option] $tSystem = _Date_Time_FileTimeToSystemTime($aTime) $tLocal = _Date_Time_SystemTimeToTzSpecificLocalTime($tSystem) $tFile = _Date_Time_SystemTimeToFileTime($tLocal) $tDate = _Date_Time_FileTimeToArray($tFile) $tOut[0] = StringFormat("%04i", $tDate[2]) ; Year $tOut[1] = StringFormat("%02i", $tDate[0]) ; Month $tOut[2] = StringFormat("%02i", $tDate[1]) ; Day $tOut[3] = StringFormat("%02i", $tDate[3]) ; Hour $tOut[4] = StringFormat("%02i", $tDate[4]) ; Minutes $tOut[5] = StringFormat("%02i", $tDate[5]) ; Seconds If $format = 0 Then Return SetError(0, 0, $tOut) Return SetError(0, 0, $tOut[0] & $tOut[1] & $tOut[2] & $tOut[3] & $tOut[4] & $tOut[5]) EndFunc ;==>FileGetTimeExt FindFiles (full recursive file search voor Win7+):
      #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include <File.au3> #include <Date.au3> #include <WinAPIShPath.au3> ; Find all files (with or without an extension) in ScriptDir with recursion FindFiles("*", 1, False) Func FindFiles($filename, $recurse = 0, $CaseSensitive = False); ; v1.0 ; Find all files matching $filename with full wildcard support, including multiple * and ? usage. ; Set $recurse to 1 to include searching all subdirectories. ; Set $CaseSensitive to True to include case sensitive searching. ; Filenames without extension demand a $filename without an extension, ; e.g. abc* matches abc.txt and abc, whereas abc*.* matches abc.txt but not abc. ; ; Use Func FoundFileProcessing($filename) to process a single found file. ; FoundFileProcessing($filename) receives filenames with full path. ; ; AutoIt Version: 3.3.14.2 ; This function requires Windows 7 or later. ; ; Requirements to include in your main program: ; #include <File.au3> ; #include <Date.au3> ; #include <WinAPIShPath.au3> If $recurse = Default Then $recurse = 0 If $CaseSensitive = Default Then $CaseSensitive = False Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "", $ssDir = "", $sDummy1 = "", $sDummy2 = "" _PathSplit($filename, $sDrive, $sDir, $sFileName, $sExtension) ; extend path to full path if filename has no path or a path relative to ScriptDir If $sDrive = "" Then _PathSplit(@ScriptFullPath, $sDrive, $ssDir, $sDummy1, $sDummy2) $sDir = $ssDir & $sDir $filename = _PathMake($sDrive, $sDir, $sFileName, $sExtension) EndIf Local $hSearch $hSearch = FileFindFirstFile(_PathMake($sDrive, $sDir, "*", ".*")) ; searches for every file and directory If $hSearch = -1 Then Return 1 Local $pattern, $eExt, $pFileName $pattern = StringMid(_PathMake("", "", $sFileName, $sExtension), 2) ; StringMid skips leading \ While 1 $sFileName = FileFindNextFile($hSearch) If @error = 1 Then ; no more files or directories match the pattern ExitLoop Else $eExt = @extended $pFileName = _PathMake($sDrive, $sDir, $sFileName, "") ; _WinAPI_IsNameInExpression supports full wildcard matching, including multiple * and ? usage. If _WinAPI_IsNameInExpression($sFileName, $pattern, $CaseSensitive) Then FoundFileProcessing($pFileName) If $eExt = 1 And $recurse = 1 Then FindFiles($pFileName & '\' & $pattern, $recurse, $CaseSensitive) EndIf WEnd FileClose($hSearch) Return 1 ; no error EndFunc ;==>FindFiles Func FoundFileProcessing($filename) ConsoleWrite('processing ' & $filename & @CRLF) EndFunc ;==>FoundFileProcessing  
      FileSetTimeEx (FileSetTime voor DST en Win7+).au3
      FileGetTimeEx (FileGetTime voor DST en Win7+).au3
      FindFiles (full recursive file search voor Win7+).au3
    • VIP
      By VIP
      My phone photos sorted by time and it very disparate.
      How do I change the time of photographing multiple photos at once?

      >> https://www.autoitscript.com/forum/topic/179038-change-date-taken-file-property-from-an-image/#comment-1287789