How to extract part of a file name using logic apps

T West 136 Reputation points
2021-05-24T02:27:49.973+00:00

Hi,

I have a Logic Apps process built which processes files uploaded onto our SFTP server.

The file naming convention is <DIGITS>_<FILENAME>. I would like to somehow extract the digits from the filename to pass as a parameter into a stored procedure.

What would be the best method of extracting the digits please? Essentially I need all numbers at the start of the file name prior to the first "_" (underscore).

Any help would be very much appreciated.

Thanks!

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,702 questions
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 66,421 Reputation points
    2021-05-24T04:49:30.187+00:00

    @T West Within the logic app you can use inline code and write javascript code to get the digit part of your filename. For testing purposes, I have defined the filename to the var text. But you can use the workflowContext object to get the fileName as mentioned in the inline code document.

    var text = "1244_test";  
    var digit= text.split('_')[0];  
    return digit;  
    

    Updated:
    You can also use split if you don't have complex logic.


0 additional answers

Sort by: Most helpful