WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Time - Timer and Date Functions
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Askitemlist files by date Example

; Listing files by date

;This script is an example of how you can sort files by Y:M:D:H:M:S (date)
;
;
;
thelist=fileitempath("C:\dateitem\*.*") ;retrieves unsorted list
askitemlist("Unsorted list of files",thelist,@tab,@unsorted,@single);debugging here
count=itemcount(thelist,@tab);counts items in list
recsize=282;record size
buff=BinaryAlloc(recsize*count)
   
   For x= 1 to count
     thefile=itemextract(x,thelist,@tab)
     thetimecode=fileymdhms(thefile)
     thefile=strfix(thefile," ",263) ;padding the string
     thefile=strcat(thefile,thetimecode)
     binarypokeStr(buff, (x-1)*recsize, thefile)
   Next 
   
BinarySort(buff,recsize,263,19,@ascending|@String);set type of sort
   
   For x=1 to count
     line=BinaryPeekstr(buff,(x-1)*recsize,263)
     line=strtrim(line)
       if x==1
         newlist=line
       else   
         newlist=StrCat(newlist,@Tab,line)
       endif   
   next

askitemlist("Files listed by date",newlist,@tab,@unsorted,@single)

message("all","Done")



Article ID:   W13883
Filename:   Sort files by date.txt
File Created: 2004:10:19:13:16:34
Last Updated: 2004:10:19:13:16:34