How to remove the file extenion from a file in a compose object?

Hopkins, Lee (Houston) 1 Reputation point
2022-04-20T14:39:49.493+00:00

I have a .csv file coming in to the compose object myfile.csv, I need to remove the .csv from the filename before it is passed Uploads a Blob to Azure Storage object.
because with in the Uploads a Blob to Azure Storage i am appending a value to the front of the file and a date time to the end than add back the .csv.

right now it is doing appendvalue_myfile.csv_01:01:xxxxxxx

194708-image.png

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

2 answers

Sort by: Most helpful
  1. Alexander Grindberg 1 Reputation point
    2022-04-22T07:10:36.527+00:00

    I would use the substring method and take the file name from start to "."

    0 comments No comments

  2. AnuragSingh-MSFT 19,686 Reputation points
    2022-04-22T11:32:18.37+00:00

    Hi @Hopkins, Lee (Houston) ,

    Welcome to Microsoft Q&A! Thanks for posting the question.

    Based on my understanding, you are trying to "compose" blob name in Comspose activity with following information:

    1. Append a value at the start of name

    2. Keep the original file name (without extension) + current time

    3. add the extension at the end of name.

    Please note that you may use available functions in expression to achieve them. There are multiple ways to achieve it. One of the ways is as mentioned by @Alexander Grindberg - using the subsctring() method to extract the name and append it with required value.

    I tested using a nested functions to achieve it using the following expression:

    concat(replace(concat('appendvalue_',replace(triggerBody()?['DisplayName'],'.csv',''),utcNow()),':','_'),'.csv')  
    

    In the example above, the following happens (order from innermost nested function to outer most)
    Consider test.csv as the file name.

    1. DisplayName from previous output is taken and extension is replaced with empty string (test)

    2. Append value as the prefix and current time(utcNow()) is added to the end of name (appendvalue_Test12022-04-22T11:19:42.0485621Z)

    3. : (colon) in blob name is replaced with _ (underscore) as some OS like Windows do not allow : in the file name. In case you are planning to process file on such OS, it might cause issues. You may skip this step, if it is not required (appendvalue_Test12022-04-22T11_19_42.0485621Z)

    4. Finally append the extension to it (appendvalue_Test12022-04-22T11_19_42.0485621Z.csv)

    Please let me know if you have any questions.

    ---
    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    0 comments No comments