dannydy Posted May 28, 2012 Posted May 28, 2012 (edited) Hi, i need some help here. basically i was trying to get the file date of modified. But i found that the date modified was different with Date last saved. Thus i need to get this date last save from excel file instead of date modified. This is my code, the return date was modified date. My file date of modified was 22/5/2012, date of last saved was 28/5/2012 which is today. Note the file was saved in the sharepoint server. Global Const $ocsfilepath = "My sharePoint pathMy excel file" Local $ocs = FileGetTime($ocsfilepath,0,0) ConsoleWrite(_filetimeconverttest($ocs[2],$ocs[1],$ocs[0],$ocs[3],$ocs[4]) & @LF) Func _filetimeconverttest($gday,$gdate,$gyear, $grab, $fmin) If $grab > 12 Then $grab = $grab -12 $x = "PM" elseif $grab = 12 Then $x = "PM" Elseif $grab = 0 Then $grab =12 $x = "AM" Else $x = "AM" EndIf $filetimeto = $gday & "/" & $gdate & "/" &$gyear & " " & $grab & ":" & $fmin & $x Return ($filetimeto) EndFunc Edited May 28, 2012 by dannydy
water Posted May 28, 2012 Posted May 28, 2012 Check this UDF. It should give you all the properties of a file. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Xenobiologist Posted May 28, 2012 Posted May 28, 2012 Did you see the other options? Global Const $ocsfilepath = "c:Dokumente und Einstellungenxf01145Eigene DateienCSVFile_2010-11-02T16_19_41.csv" Local $ocs = FileGetTime($ocsfilepath, 0, 0) ConsoleWrite(_filetimeconverttest($ocs[2], $ocs[1], $ocs[0], $ocs[3], $ocs[4]) & @LF) Local $ocs = FileGetTime($ocsfilepath, 1, 0) ConsoleWrite(_filetimeconverttest($ocs[2], $ocs[1], $ocs[0], $ocs[3], $ocs[4]) & @LF) Local $ocs = FileGetTime($ocsfilepath, 2, 0) ConsoleWrite(_filetimeconverttest($ocs[2], $ocs[1], $ocs[0], $ocs[3], $ocs[4]) & @LF) Func _filetimeconverttest($gday, $gdate, $gyear, $grab, $fmin) If $grab > 12 Then $grab = $grab - 12 $x = "PM" ElseIf $grab = 12 Then $x = "PM" ElseIf $grab = 0 Then $grab = 12 $x = "AM" Else $x = "AM" EndIf $filetimeto = $gday & "/" & $gdate & "/" & $gyear & " " & $grab & ":" & $fmin & $x Return ($filetimeto) EndFunc ;==>_filetimeconverttest Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
dannydy Posted May 29, 2012 Author Posted May 29, 2012 Thanks a lot water, this UPF was very useful. But it takes sometimes to return the file properties.
water Posted May 29, 2012 Posted May 29, 2012 Dannydy, you can pass the needed property as second parameter so it might be a bit faster. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
dannydy Posted May 29, 2012 Author Posted May 29, 2012 (edited) This is how i do, but it doesnt make any differences.... average it takes 8secs for returning the result. #include <File.au3> ; only used for the example script, not needed for the UDF #include <Array.au3> ; only used for the example script, not needed for the UDF $sFolder="sharepoinMyexcel.xlsx" ConsoleWrite("File size of = " & _FileGetProperty($sFolder, "size") & @CRLF) ; displays in the console the Size of the file ConsoleWrite("Modified Date = " & _FileGetProperty($sFolder, "Date last saved") & @CRLF) Func _FileGetProperty(Const $S_PATH, Const $S_PROPERTY = "") Local Const $objShell = ObjCreate("Shell.Application") If @error Then Return SetError(3, 0, 0) Local $iPropertyCount = 300 ; arbitrary number used, Windows 7 only returns 289 properties, Windows XP only returns 38 (future proofing) If StringLeft($S_PATH, 1) = '"' Then StringTrimLeft($S_PATH, 1) ; deletes any quotes around the pathfilename, otherwise will cause errors If StringRight($S_PATH, 1) = '"' Then StringTrimRight($S_PATH, 1) ; deletes any quotes around the pathfilename, otherwise will cause errors If Not FileExists($S_PATH) Then Return SetError(1, 0, 0) Local Const $S_FILE = StringTrimLeft($S_PATH, StringInStr($S_PATH, "", 0, -1)) Local Const $S_DIR = StringTrimRight($S_PATH, StringLen($S_FILE) + 1) Local Const $objFolder = $objShell.NameSpace($S_DIR) Local Const $objFolderItem = $objFolder.Parsename($S_FILE) If $S_PROPERTY Then For $I = 0 To $iPropertyCount If $objFolder.GetDetailsOf($objFolder.Items, $I) = $S_PROPERTY Then Return $objFolder.GetDetailsOf($objFolderItem, $I) Next Return SetError(2, 0, 0) EndIf ;Local $av_ret[300][2] = [[1]] ; For $I = 1 To $iPropertyCount + 1 ; If $objFolder.GetDetailsOf($objFolder.Items, $I) Then ;$av_ret[$I][0] = $objFolder.GetDetailsOf($objFolder.Items, $I - 1) ; $av_ret[$I][1] = $objFolder.GetDetailsOf($objFolderItem, $I - 1) ; $av_ret[0][0] += 1 ;EndIf ; Next ; ReDim $av_ret[$av_ret[0][0] + 1][2] ;If Not $av_ret[1][0] Then Return SetError(2, 0, 0) ;Return $av_ret EndFunc ;==>_FileGetProperty Edited May 29, 2012 by dannydy
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