Question

We received as input in our application (running on Windows) a list of files. These files were automatically extracted from a database with a script.

Apparently some of the names are containing special characters (like accents) and these characters are rendered as '©' on our side.

How can rename programmatically these text files (around 900'000) to get rid of this character? We cannot change the source neither re-extract the files. The problem is that because of this character another program involved with our system does not accept the files.

Was it helpful?

Solution 2

I ended up creating a new script that reads the input files and search for special characters in their title.

It was quite easy indeed:

string filename = filename.Replace("©", "e");

Since the '©' is in the filename, the script (in C#) is able to recognize it and replace the match accordingly. In this way I can loop through all the folders and subfolders simply reading the filename and change specials characters.

Thank you all for the contributions!

OTHER TIPS

Have a look at the unix command rename. It allows you to apply a perl regex to the names of a bunch of files. In this case you might want something like:

$ rename 's/[^a-zA-Z0-9]//' *

In debian the rename command is part of the perl package. It should also be available on CPAN.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top