question

HopkinsLeeHouston-0559 avatar image
0 Votes"
HopkinsLeeHouston-0559 asked AnuragSingh-MSFT commented

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

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
image.png (13.7 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@HopkinsLeeHouston-0559, Following up to see if the answers below helped. Do let us know if you have any queries.

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 Votes 0 ·
AlexanderGrindberg-5612 avatar image
0 Votes"
AlexanderGrindberg-5612 answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AnuragSingh-MSFT avatar image
0 Votes"
AnuragSingh-MSFT answered

Hi @HopkinsLeeHouston-0559,

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 @AlexanderGrindberg-5612 - 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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.