Getting a Directory Listing

Clovertech Forums Read Only Archives Cloverleaf General Getting a Directory Listing

  • Creator
    Topic
  • #51713
    David Harrison
    Participant

      Not exactly a Cloverleaf problem but I know there is a wealth of tcl knowledge in this forum.

      I need to get a list of filenames in a Windows directory in tcl.  I can get it to work in unix using the ls command:

      Code:


      set parsein “c:\lcwptest\”
      set wild “*”
      set flag “.rdy”
      set flist [ls $parsein$wild$flag]


      This doesn

    Viewing 3 reply threads
    • Author
      Replies
      • #71399
        James Cobane
        Participant

          David,

          You might want to check out the ‘glob’ and ‘file’ commands within Tcl.

        • #71400
          David Harrison
          Participant

            Thanks Jim,

            I stumbled upon the glob command and it looks like it will do the job.

            Code:

            set parsein “c:\lcwptest\”
            set flag “.rdy”
            set wild “*”
            set flist [glob -nocomplain -directory $parsein — $wild$flag]
            puts $flist

            => {c:lcwptestdave.rdy} {c:lcwptestfred.rdy}

            Regards,

            Dave

          • #71401
            Jim Kosloskey
            Participant

              David,

              If I remember correctly the glob -directory returns all of the files in the directory including links, directories, and files.

              It might be prudent to use the files command (with appropriate sub-commands) to select just the files that are directories if that is your interest.

              email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

            • #71402
              David Harrison
              Participant

                Jim (K),

                I take your point but in this case I

            Viewing 3 reply threads
            • The forum ‘General’ is closed to new topics and replies.