Fileset-Local Thread – Get Input Filename and Path

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Fileset-Local Thread – Get Input Filename and Path

  • Creator
    Topic
  • #54656
    Ian Morris
    Participant

      When processing an inbound file the default behavior of a Fileset-Local thread is to delete the input file.  I would like some guidance on how I can identify that file and make a copy of it before the thread removes it.  Thank you!

    Viewing 5 reply threads
    • Author
      Replies
      • #82447
        Sergey Sevastyanov
        Participant

          Ian,

          You can specify Directory Parse and Deletion Tcl procedure(s) in fileset local configuration.

          Both will receive list of the files in run mode.

          Directory parse will run in fileset_ibdirparse context, Deletion in fileset_ibdel context.

          You can get the list of the files with something like this:

          Code:


          keylget args MSGID mh
          set filelist [msgget $mh]

          Then you can loop through the list and do whatever you want with the files (for example, rename them with a timestamp).

          I think you can build a new list and pass it in the end with CONTINUE disposition. You probably can pass an empty list if you don’t want to delete.

          Code:


          msgset $mh [list]
          lappend dispList “CONTINUE $mh”

          I didn’t test it so please test it first.

        • #82448
          Charlie Bursell
          Participant

            You do not need to define Directory Parse/Delete routines to get file name if Fileset/Local

            Unless changed the message metadata will always contain it

            I posted this before:

            set klst [msgmetaget $mh DRIVERCTL]

            Or, if in Xlate

            set klst [xpmmetaget $xlateID DRIVERCTL]

            # Always set a default

            set filepath “”; keylget klst FILENAME filepath

            filepath will contain full path.  If you just want file name:

            set filename [file tail $filepath]

          • #82449
            Jim Kosloskey
            Participant

              If I want to archive off the files I will process with a Fileset/Local Protocol as an entire fille beforee Cloverleaf processes the file, I use a proc we have at the Directory Parse UPoC.

              Thus when the directory is parsed this proc archives the file(s) to another directory (argument specified) before Cloverleaf processes (ncluding deletes) the file.

              If I recall, this same proc can be placed at the Delete UPoC in case I want to archive the file after it has been processed but just before Cloverleaf deletes it.

              I don’t do this very often so my recollection has been clouded by time.

              The reason I do that there instead of getting the metadata is I want the process to take place before any Cloverleaf processing is done and as I recall I can’t get the metadata untill a message is read and processing has begun.

              So as is frequently true with Cloverleaf there is more than one way to achieve your goal – pick the path that gives you the result you want,

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

            • #82450
              Ian Morris
              Participant

                Thanks, Charlie!  set klst [msgmetaget $mh DRIVERCTL] was exactly what I needed.  However, I had to do some additional massaging to get purely the file name.  

                In my case the inbound file is one folder down from my PWD.

                Is there a way to pull the FILENAME based on a key rather than performing string manipulation to get down to it?

                Code:


                set fn [msgmetaget $mh DRIVERCTL]
                set filename [split $fn “/”]
                echo filename: [regsub -all {}} [lindex $filename 1] {} filename]
                echo filename:  $filename

                Charlie Bursell wrote:

                You do not need to define Directory Parse/Delete routines to get file name if Fileset/Local

                Unless changed the message metadata will always contain it

                I posted this before:

                set klst [msgmetaget $mh DRIVERCTL]

                Or, if in Xlate

                set klst [xpmmetaget $xlateID DRIVERCTL]

                # Always set a default

                set filepath “”; keylget klst FILENAME filepath

                filepath will contain full path.

              • #82451
                Scott Barrett
                Participant

                  Charlie Bursell wrote:

                  You do not need to define Directory Parse/Delete routines to get file name if Fileset/Local

                  Unless changed the message metadata will always contain it

                  I posted this before:

                  set klst [msgmetaget $mh DRIVERCTL]

                  Or, if in Xlate

                  set klst [xpmmetaget $xlateID DRIVERCTL]

                  # Always set a default

                  set filepath “”; keylget klst FILENAME filepath

                  filepath will contain full path.

                • #82452
                  Charlie Bursell
                  Participant

                    The variable is xlateId  spelling error

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