Cyri Posted December 10, 2009 Posted December 10, 2009 I'm trying to figure out the best way to see if a file/folder's creation date is today. This is what I'm currently using. #include <Date.au3> $aFileTime = FileGetTime(@WindowsDir, 1) If StringCompare($aFileTime[0] & "/" & $aFileTime[1] & "/" & $aFileTime[2], _NowCalcDate()) = 0 Then MsgBox(0, "", "created today") EndIf Is there a better way than that? I played with _DateDiff() as well, but using days it was matching stuff that occured within the last 24 hours and not actually today.
spudw2k Posted December 10, 2009 Posted December 10, 2009 (edited) You could do this. _CreatedToday(@WindowsDir) Func _CreatedToday($varFileFolder) $aFileTime = FileGetTime($varFileFolder, 1) If $aFileTime[0]&$aFileTime[1]&$aFileTime[2] = @YEAR&@MON&@MDAY Then MsgBox(0, $varFileFolder, "Created today.") Return 1 EndIf EndFunc edit: made into func. Edited December 10, 2009 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Info Posted December 10, 2009 Posted December 10, 2009 $open = FileOpenDialog("open", "", "(*)") If $open = "" Then Exit $time = FileGetTime($open, 1) ;1=creation $Year = $time[0] $Month = $time[1] $Day = $time[2] If $Year = @YEAR And $Month = @MON And $Day = @MDAY Then MsgBox(64, "", "'" & $open & "' was created today.") EndIf
Cyri Posted December 10, 2009 Author Posted December 10, 2009 You could do this. _CreatedToday(@WindowsDir) Func _CreatedToday($varFileFolder) $aFileTime = FileGetTime($varFileFolder, 1) If $aFileTime[0]&$aFileTime[1]&$aFileTime[2] = @YEAR&@MON&@MDAY Then MsgBox(0, $varFileFolder, "Created today.") Return 1 EndIf EndFunc edit: made into func. I got so hung up on trying to put the FileGetTime return back into a date format that I forgot I could just compare them using the built-in macros for year, month, and day. I like the function idea. Thanks.
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