Regex to remove all special characters from filenames?

A swapping-ground for Regular Expression syntax

Regex to remove all special characters from filenames?

Postby NotAColdSun » Thu May 18, 2023 7:51 am

I wish to remove all weird symbols from filenames, such as #, ? or ?, but the RegEx below does not work here.

([^\w\s\dÀ-ÿ???-??????ó???????Ó???_&\+\[\]\(\)\,\.\-])

Could you please, help?
NotAColdSun
 
Posts: 3
Joined: Thu May 18, 2023 7:49 am

Re: Regex to remove all special characters from filenames?

Postby NotAColdSun » Thu May 18, 2023 7:58 am

I noticed that special characters like smileys and hearts have not been recognized in the post.

To the moderators:
Please, fix the special characters
Please, delete the other post with the same question (I don’t see any button to delete a duplicate post).
NotAColdSun
 
Posts: 3
Joined: Thu May 18, 2023 7:49 am

Remove some special characters

Postby Luuk » Thu May 18, 2023 3:11 pm

This does much depend on what means 'special' characters, so please to see... http://www.bulkrenameutility.co.uk/foru ... =12&t=5639
If needing to remove more non-unicode characters like "#", would first have to present a list of these characters that are special.
The RegEx(1) could be edited to delete them all, but it might be easier putting the non-unicodes inside of "Chars" for Remove(5).
Luuk
 
Posts: 705
Joined: Fri Feb 21, 2020 10:58 pm

Re: Regex to remove all special characters from filenames?

Postby Admin » Fri May 19, 2023 2:18 am

FYI There are also some options in Remove (5)

Remove (5)

Removing parts of a filename.

This section consists of several options for removing parts of a filename. Note that these do not apply to the file extension, just the name.

· First n - Remove the first n characters from the name. E.g. removing the first 2 characters from "Joe Public.txt" will result in "e Public.txt".

· Last n - Remove the last n characters from the name. E.g. removing the last 2 characters from "Joe Public.txt" will result in "Joe Publ.txt".

· From/to - Remove a string of text, e.g. from the 6th to the 9th characters.

· Chars - Remove occurrences of characters from the name. E.g. typing "QW:#" will result in all occurrences of Q, W, colon and hash being removed.

· Words - Remove occurrences of words (separated by spaces).

· Crop - Remove any text which occurs before (or after) a specific character or word. See note below.

· Digits - Remove all occurrences of the digits 0-9 from the filename.

· High - Remove high-ASCII characters (chars from 128 to 255).

· Trim - Remove leading and trailing spaces.

· D/S - Remove occurrences of double spaces, and replace them with single spaces.

· Accent - Remove accented characters and replace them with non-accented versions. File names may contain accented characters, e.g. File names might contain à and á. Bulk Rename Utility provides a facility to replace accented characters with non-accented if needed.

· Chars - Remove all characters.

· Sym - Remove all symbols.

· Lead Dots - Remove the . and/or .. from the front of filenames (useful if you've copied from a Linux/Unix system).
Admin
Site Admin
 
Posts: 2354
Joined: Tue Mar 08, 2005 8:39 pm

Re: Regex to remove all special characters from filenames?

Postby NotAColdSun » Tue May 30, 2023 9:29 am

Thank you for your good response!

I had a look at the options, and they worked.

If there is an option to save preferences in my BRU software (even better: to save it into my username, so they stay the same on another/new computer), please, feel free to share it with me.
NotAColdSun
 
Posts: 3
Joined: Thu May 18, 2023 7:49 am


Return to Regular Expressions


cron