Is there a way to GetOldestDir

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Shadow3641
Junior Coder
Posts: 26
Joined: Thu Nov 17, 2016 2:45 pm

Is there a way to GetOldestDir

Post by Shadow3641 » Fri Jan 27, 2017 12:48 am

Hey

I have found the command to get oldest file but i need to find the oldest dir is there any way to go about doing this?
The dir names are stamped with the date in 01_26_17 format.

Code: Select all

CountDirs>C:\Users\Public\Documents\Working,fileCount,0
If>fileCount>4
GetOldestFile>C:\Users\Public\Documents\Working,oldFileName
DeleteFolder>%oldFileName%
Endif
This is what i'm trying to do but need to do it with Dirs instead of files

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Is there a way to GetOldestDir

Post by JRL » Fri Jan 27, 2017 4:44 am

There is not yet a getoldestfolder function. Until it is available we can always use DOS dir.

Code: Select all

CountDirs>C:\Users\Public\Documents\Working,fileCount,0
If>fileCount>4
Let>RP_Wait=1
Let>RP_Windowmode=0
RunProgram>cmd /c dir "C:\Users\Public\Documents\Working\*.*" /ad /o-d /b > %temp_dir%FolderList
ReadLn>%temp_dir%FolderList,1,oldFileName
DeleteFile>%temp_dir%FolderList
DeleteFolder>%oldFileName%
Endif

Shadow3641
Junior Coder
Posts: 26
Joined: Thu Nov 17, 2016 2:45 pm

Re: Is there a way to GetOldestDir

Post by Shadow3641 » Mon Jan 30, 2017 7:51 pm

Works like a charm Thanks JRL

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts