digitalexpl0it Posted May 8, 2015 Share Posted May 8, 2015 Hello,I am trying to look into multiple folders for outlook OST's. What I need is if there are more than one, delete the oldest one in that directory then move to the next directory. I am not to sure on how to compare and detect multiple OSTs in a folder. So far my script will search all the subdirectories in a given path and prompt me with the OST's found. How to I check for more than one OST and delete the oldest?Folder structure example:OSTS- user1 - User1.ost- User2 - User2.ost -User2_dup.ostEtc... ; Script Start - Add your code below here #include <Array.au3> ; Only required to display the arrays #include <File.au3> #include <MsgBoxConstants.au3> Local $sOSTDir = "\\server1\osts\" $aArray = _FileListToArrayRec($sOSTDir, "*.ost", $FLTAR_RECUR, $FLTAR_SORT) for $i = 1 to $aArray[0] $time = FileGetTime($sOSTDir & $aArray[$i], 2); 0 if for modified date $dmyyyy = $time[3]& ":" & $time[4] & ":" & $time[5]&'_'&$time[1]& "/" & $time[2] & "/" & $time[0] msgbox(0,"test", $aArray[$i] & " | Date: " & $dmyyyy) nextAny help would be appreciated. Link to comment Share on other sites More sharing options...
iamtheky Posted May 8, 2015 Share Posted May 8, 2015 expandcollapse popup; Script Start - Add your code below here #include <Array.au3> ; Only required to display the arrays #include <File.au3> #include <MsgBoxConstants.au3> Local $sOSTDir = @ScriptDir $aArray = _FileListToArrayRec($sOSTDir, "*.ost", $FLTAR_RECUR, $FLTAR_SORT , $FLTAR_FULLPATH) Global $aOut[$aArray[0] + 1][2] for $i = 1 to $aArray[0] $aOut[$i][0] = $aArray[$i] $aOut[$i][1] = FileGetTime($aArray[$i], 2 , 1); 0 if for modified date next _ArrayDelete($aOut , 0) for $i = UBound($aOut) - 1 to 1 step - 1 If stringinstr($aOut[$i][0] , "\") <> 0 Then If stringsplit($aOut[$i][0] , "\" , 2)[0] = stringsplit($aOut[$i - 1][0] , "\" , 2)[0] Then If $aOut[$i][1] < $aOut[$i - 1][1] Then _ArrayDelete($aOut , $i) Else _ArrayDelete($aOut , $i - 1) EndIf EndIf Else If $aOut[$i][1] < $aOut[$i - 1][1] Then _ArrayDelete($aOut , $i) Else _ArrayDelete($aOut , $i - 1) EndIf EndIf next _ArrayDisplay($aOut , "newest") ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
digitalexpl0it Posted May 8, 2015 Author Share Posted May 8, 2015 thank you for the reply, it seems to only pull the first created OST and not the last accessed Link to comment Share on other sites More sharing options...
iamtheky Posted May 8, 2015 Share Posted May 8, 2015 *I do see a limitation in there that my stringsplit is really only legit for stuff that is relative or one subfolder deep, definitely have to make that more robust to eliminate the plethora of cases that break it.For items relative and one subfolder deep that example should behave correctly, leaving $aOut to reflect only the item in the folder with the latest datetime (as shown in $aArray) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Jewtus Posted May 8, 2015 Share Posted May 8, 2015 Question, have you considered just using cmd?Deloldercan be executed from autoit using a run or runwait command. Link to comment Share on other sites More sharing options...
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