Cleaning up dirty filenames

Modified on Fri, 15 Nov, 2019 at 2:51 PM

Context

When building automations using files, file names could become an issue if it contains reserved characters such as "/" or spaces, or special chars such as "é" or "+",...


Slugify

The standard python environnement provides a function that will transform a dirty name into a safe name.


First of all, go to the start task of your wokrlow and select the Helpers tab

In the imports files type this line below

from django.utils.text import slugify

You can now use slugify in your workflow. 

file_base, file_ext = os.path.splitext(file_name)
file_base = slugify(file_base)
file_name = file_base + file_ext

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article