Well, ideally, I would think you would get something like windows prompt screen with 3 options:
1- Overwrite existing
2- Keep both files (Example: old "Madridi.txt" would be "Madridi (2).txt", and the new one will be "Madridi.txt")
3- Cancel
I would think same can be done for directories. But hey, I understand that this is a 3ds homebrew and it might not be as simple as that. Just giving some ideas
One thing though, would copying a directory with the same name as a file really cause a problem? files will have extensions, so it shouldn't really be a problem..?