Hey Luc,
Yes, it's possible.
Is it easy? Nyet.
Please provide a couple of real-world examples of a file name and its corresponding sort-folder.
This will make it easier to advise you.
BTW -- If you haven't read this it's worth a couple of minutes of your time.
Tip: How Do I Get The Best Answer in the Shortest Time?
-Chris