BogdanNicolescu Posted July 17, 2020 Posted July 17, 2020 Hi, I tried what is saying here: https://www.autoitscript.com/forum/topic/148232-_filegetproperty-retrieves-the-properties-of-a-file/ to get File properties: Created Date, but i'm lost. I would like to include this bit of code into another more complex, but for now, i would like to know: "How to Get Created Date from File Properties with Autoit". Thank you.
Danp2 Posted July 17, 2020 Posted July 17, 2020 See the help file entry for _Date_Time_GetFileTime Latest Webdriver UDF Release Webdriver Wiki FAQs
Subz Posted July 17, 2020 Posted July 17, 2020 Or FileGetTime("filename", 1, 1) ;~ Returns Created Date in the format YYYYMMDDHHMMSS
BogdanNicolescu Posted July 18, 2020 Author Posted July 18, 2020 On 7/17/2020 at 9:47 PM, Subz said: Or FileGetTime("filename", 1, 1) ;~ Returns Created Date in the format YYYYMMDDHHMMSS Expand Yes, i tried that already, give's me nothing.
BogdanNicolescu Posted July 18, 2020 Author Posted July 18, 2020 Ok, so ... I have a folder, where i gave a bunch of pngs. I want to get created date from those. What should i modify from here: expandcollapse popup#include <Date.au3> #include <GUIConstantsEx.au3> #include <WinAPIError.au3> #include <WinAPIFiles.au3> #include <WinAPIHObj.au3> #include <WindowsConstants.au3> Global $g_idMemo Example() Func Example() Local $hFile, $tFile, $aTime Local $sTempFile = @TempDir & "\Test.xyz" ; Create GUI GUICreate("Time", 400, 300) $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) ; Create test file and set file times $hFile = _WinAPI_CreateFile($sTempFile, 1) If $hFile = 0 Then _WinAPI_ShowError("Unable to create file") $tFile = _Date_Time_EncodeFileTime(@MON, @MDAY, @YEAR, @HOUR, @MIN, @SEC) _Date_Time_SetFileTime($hFile, $tFile, $tFile, $tFile) _WinAPI_CloseHandle($hFile) ; Read file times $hFile = _WinAPI_CreateFile($sTempFile, 2) If $hFile = 0 Then _WinAPI_ShowError("Unable to open file") $aTime = _Date_Time_GetFileTime($hFile) _WinAPI_CloseHandle($hFile) MemoWrite("Created ..: " & _Date_Time_FileTimeToStr($aTime[0])) MemoWrite("Accessed .: " & _Date_Time_FileTimeToStr($aTime[1])) MemoWrite("Modified .: " & _Date_Time_FileTimeToStr($aTime[2])) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE FileDelete($sTempFile) EndFunc ;==>Example ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite With what so i can get what i want? Thank you.
TheXman Posted July 18, 2020 Posted July 18, 2020 (edited) Why are you making the script more complex than it needs to be? expandcollapse popup#AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $g_idMemo Example() Func Example() Const $sTempFile = @TempDir & "\Test.xyz" ; Create GUI GUICreate("Time", 400, 300) $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) ; Create temp file If Not FileWrite($sTempFile, "") Then Exit MsgBox($MB_ICONERROR+$MB_TOPMOST, "ERROR", "Unable to write temp file.") MemoWrite("Created ..: " & FileGetTime($sTempFile, $FT_CREATED , $FT_STRING)) MemoWrite("Accessed .: " & FileGetTime($sTempFile, $FT_ACCESSED, $FT_STRING)) MemoWrite("Modified .: " & FileGetTime($sTempFile, $FT_MODIFIED, $FT_STRING)) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE FileDelete($sTempFile) EndFunc ;==>Example ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Edited July 18, 2020 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
BogdanNicolescu Posted July 19, 2020 Author Posted July 19, 2020 On 7/18/2020 at 7:59 PM, TheXman said: Why are you making the script more complex than it needs to be? expandcollapse popup#AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $g_idMemo Example() Func Example() Const $sTempFile = @TempDir & "\Test.xyz" ; Create GUI GUICreate("Time", 400, 300) $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) ; Create temp file If Not FileWrite($sTempFile, "") Then Exit MsgBox($MB_ICONERROR+$MB_TOPMOST, "ERROR", "Unable to write temp file.") MemoWrite("Created ..: " & FileGetTime($sTempFile, $FT_CREATED , $FT_STRING)) MemoWrite("Accessed .: " & FileGetTime($sTempFile, $FT_ACCESSED, $FT_STRING)) MemoWrite("Modified .: " & FileGetTime($sTempFile, $FT_MODIFIED, $FT_STRING)) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE FileDelete($sTempFile) EndFunc ;==>Example ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Expand That was the example from the help file of docs/libfunctions/_Date_Time_GetFileTime.htm ..... I dind't write a thing :)) I just try to figure out how do i do to get the Created date of a file.
Subz Posted July 19, 2020 Posted July 19, 2020 On 7/18/2020 at 7:34 PM, BogdanNicolescu said: Yes, i tried that already, give's me nothing. Expand Well I ran it across my desktop and it works fine, so please post what you tried, here is my desktop script: #include <File.au3> Global $g_aPNGList = _FileListToArrayRec(@DesktopDir, "*.png", 1, 1, 0, 2) If @error Then Exit MsgBox(4096, "Error", "Unable to create file list.") Global $g_sPNGCreated For $i = 1 To $g_aPNGList[0] $g_sPNGCreated = FileGetTime($g_aPNGList[$i], 1, 0) ConsoleWrite($g_aPNGList[$i] & " = Created DD/MM/YYYY HH:MM:SS : " & $g_sPNGCreated[2] & "/" & $g_sPNGCreated[1] & "/" & $g_sPNGCreated[0] & " " & $g_sPNGCreated[3] & ":" & $g_sPNGCreated[4] & ":" & $g_sPNGCreated[5] & @CRLF) Next
BogdanNicolescu Posted July 19, 2020 Author Posted July 19, 2020 On 7/19/2020 at 3:48 AM, Subz said: Well I ran it across my desktop and it works fine, so please post what you tried, here is my desktop script: #include <File.au3> Global $g_aPNGList = _FileListToArrayRec(@DesktopDir, "*.png", 1, 1, 0, 2) If @error Then Exit MsgBox(4096, "Error", "Unable to create file list.") Global $g_sPNGCreated For $i = 1 To $g_aPNGList[0] $g_sPNGCreated = FileGetTime($g_aPNGList[$i], 1, 0) ConsoleWrite($g_aPNGList[$i] & " = Created DD/MM/YYYY HH:MM:SS : " & $g_sPNGCreated[2] & "/" & $g_sPNGCreated[1] & "/" & $g_sPNGCreated[0] & " " & $g_sPNGCreated[3] & ":" & $g_sPNGCreated[4] & ":" & $g_sPNGCreated[5] & @CRLF) Next Expand NOW! This is ENTIRE different thing then what i have read ... Yes, it works .... but now ... how do i change the dir? Thank you.
Developers Jos Posted July 19, 2020 Developers Posted July 19, 2020 On 7/19/2020 at 7:58 AM, BogdanNicolescu said: Yes, it works .... but now ... how do i change the dir? Expand What do you mean? Run this script for another directory? If that is really the question it is time you have a closer look at the script yourself and try to understand it as the answer is pretty obvious. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
BogdanNicolescu Posted July 19, 2020 Author Posted July 19, 2020 On 7/19/2020 at 8:24 AM, Jos said: What do you mean? Run this script for another directory? If that is really the question it is time you have a closer look at the script yourself and try to understand it as the answer is pretty obvious. Jos Expand I'm clueless ... can you throw me a hint? I imagine it has to do somthing with this: @DesktopDir But i don't see how, as my folder resides in another partition. How do i change that to something like this: F:\++\Folder340\_+_\2020\07 2020\Folder890 Or, how do i make it found Folder890? Thank you.
Developers Jos Posted July 19, 2020 Developers Posted July 19, 2020 On 7/19/2020 at 8:32 AM, BogdanNicolescu said: How do i change that to something like this: F:\++\Folder340\_+_\2020\07 2020\Folder890 Expand Come on....Did you try at all? Maybe open the Helpfile (F1) so you can find that information? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
BogdanNicolescu Posted July 19, 2020 Author Posted July 19, 2020 On 7/19/2020 at 8:35 AM, Jos said: Come on....Did you try at all? Maybe open the Helpfile (F1) so you can find that information? Jos Expand Looked at that f1 thingy ... it spit me right back in my face 😄😄 I would much rather use something like this: FileSelectFolder ( "dialog text", "root dir" [, flag = 0 [, "initial dir" [, hwnd]]] ) if it's possible, but i don't know where to insert it.
Developers Jos Posted July 19, 2020 Developers Posted July 19, 2020 So you spent about 1 minute to try and understand? Try harder and come back when you have something to show for. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
BogdanNicolescu Posted July 19, 2020 Author Posted July 19, 2020 On 7/19/2020 at 8:43 AM, Jos said: So you spent about 1 minute to try and understand? Try harder and come back when you have something to show for. Expand I'm blonde 😁😂
BogdanNicolescu Posted July 19, 2020 Author Posted July 19, 2020 On 7/19/2020 at 8:43 AM, Jos said: So you spent about 1 minute to try and understand? Try harder and come back when you have something to show for. Expand I have read and tried all of this list: https://www.autoitscript.com/autoit3/docs/macros.htm#%40DesktopDir I don't catch what should i use ...
Developers Jos Posted July 19, 2020 Developers Posted July 19, 2020 Show what you have tried and isn't working.... we are not going to do the work for you. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
BogdanNicolescu Posted July 19, 2020 Author Posted July 19, 2020 On 7/19/2020 at 9:10 AM, Jos said: Show what you have tried and isn't working.... we are not going to do the work for you. Expand I treid all @ from that list, including (for the fun of it) @DesktopHeight, but now i tried something different, something that it dose not require "@" #include <File.au3> Global $g_aPNGList = _FileListToArrayRec ("F:\++\Folder340\_+_\2020\07 2020\Folder890", "*.png", 1, 1, 0, 2) If @error Then Exit MsgBox(4096, "Error", "Unable to create file list.") Global $g_sPNGCreated For $i = 1 To $g_aPNGList[1] $g_sPNGCreated = FileGetTime($g_aPNGList[$i], 1, 0) ConsoleWrite($g_aPNGList[$i] & " = Created DD/MM/YYYY HH:MM:SS : " & $g_sPNGCreated[2] & "/" & $g_sPNGCreated[1] & "/" & $g_sPNGCreated[0] & " " & $g_sPNGCreated[3] & ":" & $g_sPNGCreated[4] & ":" & $g_sPNGCreated[5] & @CRLF) Next The problem is that it does not show me neither an error, or a result, just that it has finished nothing :))
BogdanNicolescu Posted July 19, 2020 Author Posted July 19, 2020 (edited) Now, when i use this: #include <File.au3> Global $g_aPNGList = _FileListToArrayRec ("F:\++\Folder340\_+_\2020\07 2020\Folder890, "*.png"", 1, 1, 0, 2) If @error Then Exit MsgBox(4096, "Error", "Unable to create file list.") Global $g_sPNGCreated For $i = 1 To $g_aPNGList[1] $g_sPNGCreated = FileGetTime($g_aPNGList[$i], 1, 0) ConsoleWrite($g_aPNGList[$i] & " = Created DD/MM/YYYY HH:MM:SS : " & $g_sPNGCreated[2] & "/" & $g_sPNGCreated[1] & "/" & $g_sPNGCreated[0] & " " & $g_sPNGCreated[3] & ":" & $g_sPNGCreated[4] & ":" & $g_sPNGCreated[5] & @CRLF) Next It says that autoit has stopped working 😂 Edited July 19, 2020 by BogdanNicolescu
BogdanNicolescu Posted July 19, 2020 Author Posted July 19, 2020 this is the corect answer: #include <File.au3> Global $g_aPNGList = _FileListToArrayRec("F:\++\Folder340\_+_\2020\07 2020\Folder890", "*.png", 1, 1, 0, 2) If @error Then Exit MsgBox(4096, "Error", "Unable to create file list.") Global $g_sPNGCreated For $i = 1 To $g_aPNGList[0] $g_sPNGCreated = FileGetTime($g_aPNGList[$i], 1, 0) ConsoleWrite($g_aPNGList[$i] & " = Created DD/MM/YYYY HH:MM:SS : " & $g_sPNGCreated[2] & "/" & $g_sPNGCreated[1] & "/" & $g_sPNGCreated[0] & " " & $g_sPNGCreated[3] & ":" & $g_sPNGCreated[4] & ":" & $g_sPNGCreated[5] & @CRLF) Next Thank you all
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now