How to handle special characters in filenames using Switch

Integration 1 min read , November 18, 2021

contributed by agileStreams

There are many cases where filenames can generate problems, especially between different operating systems (e.g. Mac or Windows) or when transferring files to a webserver. In particular, spaces, special characters, or diacritics in filenames can be wrongly translated or even avoid file saving.

What is a diacritic?

Even if you never heard about the name, you surely dealt with diacritics before. A diacritic is a glyph added to a letter that somehow alters its pronunciation and which appears above, below, within or between letters — French uses five diacritics: the grave, acute, and circumflex accents, as well as the cedilla and dieresis.

Filename Cleaner Pro is a Switch app that will clean your filenames, in an easy way.

Scenario 1: make a clean and readable URL

Sometimes, URL are very difficult to read because of spaces or special characters in the name, as these characters have to be escaped to be compatible with web standards. This makes URL very difficult to read (at best) or makes it impossible to download the file!

As you can see in the example below, the URL is not easy to read… but even, the webserver cannot find the file, as the special characters in the filename have been wrongly converted, due to different character encoding.

If you want to get rid of this issue, the best is to avoid using diacritics, spaces, reserved characters, etc., but this takes quite some time to rename the files, and there is a chance that you forget about one.

Configure Filename Cleaner Pro just like below and all your files will be renamed in a way that they will not cause errors anymore:

In this case, the filename will be converted to lowercase, all diacritics will be replaced by their equivalent without alteration, the spaces will be replaced by a dash, and the reserved/special characters will be discarded.

Our file, named « Voix ambiguë d'un cœur qui au zéphyr préfère les jattes de kiwis.pdf » will be renamed « voix-ambigue-dun-coeur-qui-au-zephyr-prefere-les-jattes-de-kiwis.pdf ».

The URL is now easier to read, and the filename will not cause any issue anymore.

You can configure a Switch flow where all files dropped in the input folder will be renamed according to the setting above, transferred via FTP to the web server and send an email with the URL of the file (with its new name), so you can easily send the link to someone else.

Scenario 2: transfer files between platforms

The different platforms (e.g. Mac or Windows) are using different character encoding (e.g. MacRoman or ISO-8859-1) and have different forbidden characters. For example, “\” is allowed in a filename on Mac, but is forbidden on Windows (as this is the separator for sub-folders). Cleaning filenames to avoid transfer errors, or simply to have identical names on all workstations or servers of an organization, regardless of which type they are, would need users’ manual renaming, taking time and introducing risk in the renaming process (typos, forgotten characters, etc.).

Here again, adding a Filename Cleaner Pro module in your Switch flow before file transfer or archive can solve this issue. In that case, we will configure it, just to convert diacritics and replace reserved characters by an underscore (or any combination that would do it for you):

In case you have issues with the length of your filename, you can also add a truncation during the renaming process to handle this in one process. Filename Cleaner Pro can truncate from the beginning of the name (enter a positive number) or from the end (enter a negative number).

How to get back to the original filename

Filename Cleaner Pro offers two specific settings to remember the original filename, using private data and/or using XMP. While the first will allow to retrieve the original filename later in a Switch flow, the latter will embed the original filename as XMP into the file itself (typically graphic, audio and video files can embed XMP, e.g. PDF, TIFF, PNG, MP4, etc.). That means that you will be able to retrieve the original filename, even if the file has been transferred to many systems, downloaded, or even modified.

Switch Appstore