7 Replies Latest reply on Jan 2, 2020 1:25 PM by Cathy Amore

    Filename variable without extension

    Cathy Amore
      Share This:

      Hello,

       

      I am looking to create two variables when a filewatcher successfully finds a file.  One with the filename with extension and one with filename without extension.  the %FILENAME% saves the filename with the extension to the variable.  How can I create another variable that will have the file found WITHOUT the extension?

       

      Thanks!

        • 1. Re: Filename variable without extension
          Mark Francome

          Within a File Transfer job, if you have successfully watched a file using a variable, you can share that variable to an additional transfer in the Source path within the same job using the following variables:

           

          • $$WATCH_ALLn$$: Determines the full file name including the extension of the successfully watched file
          • $$WATCH_NAMEn$$: Determines the file name only without the extension of the successfully watched file
          • $$WATCH_EXTn$$: Determines the extension of the successfully watched file.

           

          NOTE: n represents the number of the watch/transfer of the possible 5 in the job.

          If you selected the Rerun from point of failure checkbox, you cannot use the above variables.

           

          And within the advanced general parameter settings (still using File Transfer jobs) -

           

          The File name field in the After the completion of a successful file transfer the source file will be, After the completion of a successful file transfer the destination file will be and Create Empty File fields parameters can contain variables, constants, and the following variables:

          • AFTFILE$$: Contains the name of the original file without file extension. (If there was an extension, it is always added to the name of the file.)
          • $$AFTFILE_ALL$$: Contains the full file name including the extension
          • $$AFTFILE_NAME$$: Contains only the name of the file until the last dot (without the extension).
          • $$AFTFILE_EXT$$: Contains only the extension of the file name

          EXAMPLE: If you want to rename a transferred file old_cmd_060101.exe, when it was originally named cmd.exe, the pattern you must specify is old_$$AFTFILE$$_%%DATE.

          3 of 3 people found this helpful
          • 2. Re: Filename variable without extension
            Tully Krastins

            Hi Cathy,

             

            What Operating System are you working with?

            • 3. Re: Filename variable without extension
              Mark Francome

              And, if your file names are of standard length, you can use the %%SUBSTR feature to extract the desired portion of the variable.

              • 4. Re: Filename variable without extension
                Cathy Amore

                Hi Tully,

                 

                Unix.  I actually found something that works.  With the filewatcher I am saving the file found to a variable in the advanced options.  I then created an OS job to run after this that echoes that variable and I take off the extention with an xargs command.  I then capture the filename without the extension in the capture output action to save that to a variable.

                1 of 1 people found this helpful
                • 5. Re: Filename variable without extension
                  Cathy Amore

                  Hi Mark!

                   

                  I actually found something that works.  With the filewatcher I am saving the file found to a variable in the advanced options.  I then created an OS job to run after this that echoes that variable and I take off the extention with an xargs command.  I then capture the filename without the extension in the capture output action to save that to a variable.  The problem with using the $$AFTFILE$$ options was that I need to use the filename in a job later downstream and not in the original filewatcher/FTP job.

                   

                  Thanks for you input!

                  • 6. Re: Filename variable without extension
                    Mun Keong Lee

                    Hi Cathy

                    Not sure whether you are looking into filewatcher job or ftp job. If you are working on a filewatcher job, you can try the following solution which does not require an additional OS job.

                     

                    A filewatcher will have a line that looks like this if it's watching for a file, /tmp/*.txt.

                    1204 09:44:33 : File transfer was completed. The size of file '/tmp/test.txt' is 9 bytes. id=1. Modified 04/12/2019 09:43

                     

                    For V9 and above, you can make use of "Capture from job output" feature. Since another job will be making use these variables, you have to use either Global or Named Pool variable. In my example below, I'm using Global variables.

                     

                    To capture filename including extension:

                    To capture filename without extension:

                     

                     

                    Regards,

                    MK

                    1 of 1 people found this helpful
                    • 7. Re: Filename variable without extension
                      Cathy Amore

                      Thank you Tully and Mark!  I did not see that I could use a . as the delimiter in the capture!  That works perfectly!  Thank you for all your help!

                       

                      Cathy Amore

                      Application Technical Analyst

                      tel 734-343-0472

                      amorecj@trinity-health.org<mailto:amorecj@trinity-health.org>

                      Trinity Health | 20555 Victor Parkway | Livonia, MI 48152

                      Open a ticket for Control-M Here:

                      http://uthdchsmagp0027.trinity-health.org/ops_automation/ticket.php