PDA

View Full Version : Loop through files in order of date created



samuelimtech
06-23-2016, 02:06 AM
Hi all,

first off thanks for any help.

im using the below code to loop through files but it automatically loops through the files alphabetically, is it possible to modify such that the loop is sorted by Date modified (earliest first)?

thanks


MyFile = Dir(MyPath)Do While MyFile <> ""
'do stuffs
MyFile = Dir
Loop

snb
06-23-2016, 04:17 AM
sub M_snb()
sn=split(createobject("wscript.shell").exec("cmd /c Dir G:\OF*.* /b/o-d").stdout.readall,vbcrlf)

for j=0 to ubound(sn)-1
msgbox sn(j)
next
end sub