I have accidentally named a folder with an added space at the end on Linux. On Windows 10, this is not even possible, the space at the end is automatically deleted. On Linux Mint 19.2, this is possible, and it caused trouble when trying to access that folder back on Windows.
As soon as I copied an additional file into that folder, the folder was renamed by Windows to a foldername without a space at the end, with the result that TWO folders, one with the space at the end, one without and looking fully alike, were shown in Windows Explorer. BOTH folders had only the newly pasted file in it, with the rest of the files not shown.
First try to solve it:
After adding a suffix to the the folder with the space at the end and re-opening the Windows Explorer, I could also see the old files in the folder without a space at the end. I could also save these files somewhere else. Thus, the Linux files are just visually suppressed by the Windows Explorer folder manager, the newly pasted file and its assigned folder dominates everything that was in there before.
Problem2: I moved all files to a new folder without that problem. Then I tried to delete the folder that was corrected by Windows, but that did not exist! It was just visually pretended to be there. And I had to revert the renaming and the moving of the folder with the space ending in order to delete the folder without the space corrected by Windows.
Go back to Linux and remove the space ending, then go back to Windows and any file can be pasted as always.
But this solution is quite awkward.
It is especially if I somehow had even managed to delete the folder with the space ending on Windows (what I did not, but who knows how this might have happened else-wise?), since then, on Windows, I would not even have any chance to delete the corrected folder. I would have to create a new folder WITH a space on Linux in that same folder again only in order to be able to delete the folder WITHOUT a space. And then I would again have to go back to Linux as the solution says.
With or without deleting the folder on Windows, such confusion just because of space endings can happen to any user switching between Linux and Windows.
Thus the question:
On Linux, is there a setting that automatically removes the space(s) at the end of foldernames the same way as on Windows 10, meaning at the time of the change itself?
The problem was on an exfat SD-card, though I guess that it happens with NTFS as well. One could also see this not as a Linux, but as a pure Windows file management problem. That is why the Windows question as "the other side" is now on Super User with Windows 10: How to deal with foldernames ending with space(s) that are allowed on Linux but cannot be used any further in Windows Explorer?. Please answer here for the Linux solution, and there for the Windows solution.