"Below uses a split to allow us to isolate the file type or extension as well as the file name. It breaks into 2 minus the dot (period). This will work perfectly, assuming there are no dots in the file name itself."

There have been a lot of users in the community contact me saying that these processes work very well for them, although a couple who have mentioned they have "dots" (periods) in their file names hence there can be issues with the flow. This post will address that, so if we consider a file name called "this=is&a.spreadsheet.03.19.xlsx" then we will split this into 2 whilst stripping out any potential problem characters, dots, ampersands, equals signs etc.

So we started with …

File Name:this=is&a.spreadsheet.03.19.xlsx

We will be left with …

File Name:thisisaspreadsheet0319

File Extension:.xlsx

We can then incorporate this process to the Flow I have referenced at the beginning or any other Flow that has issues relating to file names (or any string really) contaning dots, or special characters.

In order to start off this simulated process, I will start with a button. This just means it is easy to test and helps you get the concept of what we are actually doing.

Let's simulate the file name using a "Compose", renamed to "Compose File Name With Dots".

Note: There will be several "Compose" actions used in this Flow, just rename them exactly as you see them and you will be able to copy and paste the code.

Note: You will probably replace this in production by targeting which ever value is relevant. Attachment Name perhaps when working with Outlook Email.

this=is&a.spreadsheet.03.19.xlsx

Now let's Split of just the file extension (xlsx in this case)

last(split(outputs('Compose_File_Name_With_Dots'), '.'))

Let's create the actual file extension by adding the dot with the concat() function.

concat('.', outputs('Compose_Split_At_Dot'))

This next step will now target the remainder of the file name, the bit we will want to clean up or sanitise.

We will have to loop through our problematic file name in order to clean out the dots, or special characters so let's use "Apply to each", name it accordingly perhaps.

Now some "Set variable" actions, again helpfully named accordingly

replace(variables('CleanFileName'), item(), ")

This now means, when we use a final "Compose" action called "Compose CleanFileName" so we can easily see the result of the variable "CleanFileName" we have a sanitised string.

Result.

Result.

Try it for yourself, rebuild this flow and enter varying values in "Compose File Name With Dots". As long as the character you want to strip out is contained within "Initialize Variable InvalidCharacters" then it will be removed from the string. Should you want to add additionla charaters to this array or perhaps, remove characters from the array then please do.

COMING SOON: The #PowerApps and #MicrosoftFlow User Group will be coming to the #BlackCountry to share the best advice, guidance, best practice, knowledge and ideas. Calling out to users in #Stourbridge, #Halesowen, #BrierleyHill, #Birmingham, #Worcester or surrounding areas