232showtime Posted June 5, 2016 Posted June 5, 2016 (edited) I was wondering if can Get Folder name with latest Date in a Folder is possible, becuase I dont know which command I should search for. thanks in advance Edited June 5, 2016 by 232showtime ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon.
AutoBert Posted June 5, 2016 Posted June 5, 2016 You can use _FileListToArray to get a array of all Folders. Use _ArrayColInsert to insert the col for the date. Loop through the array and use FileGetTime for getting time of each Folder. Whenn you use _ArraySort to sort the Array by Col1 descending in Col 1 of first returned Folder in Array is the newest. Spoiler #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $sPath="C:\Program Files\AutoIt3" ;here your Path Local $aRet=_GetAllFolders($sPath,'d') if @error Then Exit MsgBox($MB_ICONERROR,'Folders: '&$sPath,'Error: '&@error & ' occured'& @CRLF&'Extended: '&@extended) _ArrayDisplay($aRet) MsgBox($MB_ICONINFORMATION,'Last modified Folder',$aRet[1][0]&' '&$aRet[1][1]) EndFunc func _GetAllFolders($sPath, $sSortBy) Local $aFolders = _FileListToArray($sPath, '*', 2) If @error Then Return SetError(@error, @extended, 0) _ArrayColInsert($aFolders,1) ;col for Last modified For $iFolders=0 to $aFolders[0][0] $aFolders[$iFolders][1]=FileGetTime($sPath&'\'&$aFolders[$iFolders][0],0,1) Next if $sSortBy='d' Then _ArraySort($aFolders,1,1,0,1) Return $aFolders EndFunc 232showtime 1
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