tcl – Checking for files

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf tcl – Checking for files

Viewing 3 reply threads
  • Author
    Replies
    • #57031
      Ayan George
      Participant

        pretty easy.  lets say you have a variable called “flagFile” that contains the name of a file with a .flg extension.  you can do the following:

        Code:


        set datFile “[ file rootname $flagFile ].dat”

        David Harrison wrote:

        I

      • #57032
        David Harrison
        Participant

          That pre-supposes that I know the filename but I don

        • #57033
          David Harrison
          Participant

            OK I’ve worked out how to do it. In unix:

            set fname [ls /export/home/cloverleaf/capture/*.flg]

          • #57034
            Jim Kosloskey
            Participant

              You could use the tcl glob command which returns a list of all entries found matching a glob pattern. I would use the nocomplain switch so that an empty set would not throw an error.

              If you are concerned that a subdirectory might match the pattern, you could then work the list using ‘file isfile’ or ‘file isdirectory’.

              Jim Kosloskey

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

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