File Extensions

Hi

Does anyone have any idea how to auto adjust dynamically file extensions?

I have a bot that will go into SAP and download a bunch of attachments. However, sometimes it might be .TIF, .JPG, .xlsx, .PDF. In the screenshot, the bot renames the files based on the current SAP Document Number (Variable: FileName) that it has open. But I’m looking for ways to dynamically change the file extension. Any ideas?

image

Hi @neeta.joji ,

You could try using a Get Text Activity and replace everything after the period with the extension you want:

image

System.Text.RegularExpressions.Regex.Replace(str_retrievedText,"(?<=\.).*","xlsx")

If this is not what you were looking for, then please provide more details so that we may be in a better position to assist you.

Kind Regards
Ashwin A.K

Hi,

Another solution:

In this case, we can use GetExtension method and GetFileNameWithoutExtension method.

System.IO.Path.GetExtension method returns extension. for example, System.IO.Path.GetExtension("209267517.PDF") returns ".PDF"

System.IO.Path.GetFileNameWithoutExtension method returns filename without extension. for example, System.IO.Path.GetFileNameWithoutExtension("209267517.PDF") returns "209267517"

Regards,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.