I have this scrit that runs wherever any folder are created in a workspace, the script runs automatically trough folder rules and works fine, except when the destination folder already exists, I give a look at source code of the page itself and notice that even that apears to have 2 folders with the same name (impossible with alfresco rules), turns out that the source code for the folder tiltle has a ' ' caracter in spaces, so when my script compares the two folders name "ATESTADOS MÉDICOS" with "ATESTADOS MÉDICOS", visually they are the same because html puts a space at ' ' location, when my script compares they are not the same.
Now I Have two change all the ' ' im my folders name.
I am not sure what is the full functionalities and steps that script is performing and trying to achieve. However, you can just cleanup the two names before comparision. (whitespace) is an html entity which you can cleanup using some regex and then compare the values.