Jump to content

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


Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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! :)

Link to comment
Share on other sites

  • Moderators

meows,

Delighted to hear it. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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
 Share

×
×
  • Create New...