To use this file copy and paste this:
// #URL-lib "http://pin1.org/forthlib/flb/SD-Card/fat-2.flb" into BV Terminal 3
or here to download.
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// FAT formmatted SD card access
// ========== P A R T 2 ======================================
// This is the directory listing and handleing, uses the device
// buffer to read and write the directory sections. The operations
// performed in this section are for reading, directory writing
// is in a later section.
// NOTE This shares many words with fat-1-a and so the SID numbers
// Must be the same.
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// HISTORY:
// Mar 2008 * Replaced [char] : with 58 emit because BVT gets confused
// REQUIRES:
// #URL-Inc "http://pin1.org/forthlib/flb/General/soft1.flb" sid=99
// #URL-lib "http://pin1.org/forthlib/flb/General/pinsel.flb" sid=100
// #URL-lib "http://pin1.org/forthlib/flb/General/SPI.flb" sid=101
// #URL-lib "http://pin1.org/forthlib/flb/SD-Card/MMC.flb" sid=102
// #URL-lib "http://pin1.org/forthlib/flb/SD-Card/fat-1.flb"
//
// CONSTANTS:
// convenient to hold current file name here i think
12 vspace$ dir$
//
// constants used as an offset into the directory for either creation
// or modification times.
14 constant created // offset for creation and modifed dates
22 constant modified
//
Full Contents of File
12  vspace$  dir$
14  constant  created     
22  constant  modified
: dir-entry
    32  *         
    BytesSec  d  @  u
    Dir  d  @  +         
    dup  d-sec  <>   
        if
            dsec@     
        else
            drop       
        then
    dbuff  +   
;
: dirAdd  direntry  f  ; 
   
: filename@  dir$  11  move  0  dir$  12  +  c!  dir$  ; 
: attrib@  11  +  c@  ;
: start-clust@  dup  20  +  word16  16  lshift  swap  26  +  word16  +  ;
: c-dir-time  created  +  word16  ; 
: m-dir-time  modified  +  word16  ; 
: c-hours@  c-dir-time  11  rshift  ;
: m-hours@  m-dir-time  11  rshift  ;
: c-minutes@  c-dir-time  5    rshift  &3f  and  ;
: m-minutes@  m-dir-time  5    rshift  &3f  and  ;
: c-seconds@  c-dir-time  &1f  and  ;
: m-seconds@  m-dir-time  &1f  and  ;
: c-dir-date  created  +  2  +  word16  ; 
: m-dir-date  modified  +  2  +  word16  ; 
: c-year@  c-dir-date  9  rshift  1980  +  ;
: m-year@  m-dir-date  9  rshift  1980  +  ;
: c-month@  c-dir-date  5    rshift  &f  and  ; 
: m-month@  m-dir-date  5    rshift  &f  and  ; 
: c-day@  c-dir-date  &1f  and  ;
: m-day@  m-dir-date  &1f  and  ;
: filesize@  dup  28  +  word16  swap  30  +  word16  16  lshift  +  ; 
: packtime
    h  11  lshift
    m  5  lshift  +
    s  +
;
: packdate
    y  1980  -  9  lshift
    m  5  lshift  +
    d  +
;
: filename!  11  move  ;
: attrib!      11  +  c!  ;
: start-clust! 
    >r  dup  16  rshift  r@  20  +  word16! 
    &ffff  and  r>  26  +  word16!  ; 
: c-time!  packtime  swap  14  +  word16!  ;
: c-date!  packdate  swap  16  +  word16!  ;
: m-time!  packtime  swap  22  +  word16!  ;
: m-date!  packdate  swap  24  +  word16!  ;
: filesize! 
    >r  dup  16  rshift  r@  20  +  word16! 
    &0000ffff  and  r>  28  +  word16!  ; 
: dir-date.
    dup  m-day@  <#  #  #  #>  stype  [char] 
    dup  m-month@  <#  #  #  #>  stype  [char] 
            m-year@  <#  #  #  #  #  #>  stype
;           
                   
: dir-time.
    dup  m-hours@  <#  #  #  #>  stype  58  emit
    dup  m-minutes@  <#  #  #  #>  stype  58  emit
            m-seconds@  <#  #  #  #>  stype
;
: dir.
    dup  cr  filename@  stype  tab     
    dup  dir-date.  space  dup  dir-time.  tab 
    dup  start-clust@  .
    tab  filesize@  .
;               
: ls
    -1  =>  d-sec     
    RootEntries  d  @     
    for
        i  dir-entry   
        dup  c@  0= 
        if 
            drop 
            unloop  escape 
        then
        c@  &e5  <>  if  i  dir-entry  dir.  then
    next
;
: dot2pad
int:  len  Ic  Oc       
v$:  tmp  13             
        %@  tmp  11  bl  fill     
        s-add  length  =>  len   
        begin             
                s-add  Ic  +  c@       
                dup  46  =               
                if
                        1  +>  Ic         
                        8  =>  Oc         
                        drop
                else       
                        %@  tmp  Oc  +  c!
                        1  +>  Ic         
                        1  +>  Oc 
                then       
        Ic  len  1-  > 
        until
        0  %@  tmp  11  +  c!       
        %@  tmp  toupper         
; 
: dir-search
int:  str
        dot2pad  =>  str     
        RootEntries  d  @ 
        for
            i  dir-entry     
            dup  c@  0=  if  drop  0  unloop  escape  then     
            str  swap  s=         
            if
                i 
                -1  leave     
            then                   
        next
;
: <0>f.device  =>  d#  ; 
: <0>f.find  dir-search  ;
: <0>f.ls  ls  ;