Remove special characters from file name-Remove round brackets ( )

How to remove brackets from file name .Ihave used below replace activity to remove brackets but still throwing error. I want to remove the brackets from my file name and replace with -
image
image

Hi @marina.dutta

What are special characters you would like to remove and replace with.

Regards

@vrdabberu

( ).|/?:

1 Like

Hi @marina.dutta

Do you want to remove only these specials characters?

( ).|/?:

Regards

@vrdabberu

<>/|():.

Hi @marina.dutta

By using the below regex expression you can remove all the special characters.

[^A-Za-z0-9]

Regards

@vrdabberu

even this / \ forward and backward slash

Hi @marina.dutta

Yes even that can be replaced.

Regards

@vrdabberu

same expression shall i use what you gave?

HI @marina.dutta

Yes you can use the same expression but after replacing you need to add an . before pdf so use the below syntax in assign activity.

Input = "cvhvds\/.';.!WR^R#E#%@()/\\///\\*&%#*@sdbchsgdvchds.pdf"

Output = System.Text.RegularExpressions.Regex.Replace(Input,"[^A-Za-z0-9]","")

NewFileName = Output.Insert(Output.Length-3,".")

Regards

@vrdabberu

Its removing the date and spaces .

I want something like this Candour Communications Private Limited India_GGN-23-24-152_27-Oct-23 as the file name.

Now I am getting like CandourCommunicationsPrivateLimitedIndiaGGNOct

Hi @marina.dutta

Can you share the sample input file name exactly please

Regards

@vrdabberu

This is the file name . I want to remove slashes bracket and any other special characters

Candour Communications Private Limited (India)_GGN/23-24/152_27-Oct-23.pdf

Hi @marina.dutta

Please use the below regex

Input = "Candour Communications Private Limited (India)_GGN/23-24/152_27-Oct-23.pdf"
Output = System.Text.RegularExpressions.Regex.Replace(Input,"[^A-Za-z0-9 _-]","")
NewFileName = Output.Insert(Output.Length-3,".")

Regards

1 Like

@vrdabberu

Thank You

1 Like

You’re welocme @marina.dutta

Happy Automation

Regards

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