Files and folders that resist the deletion command in Windows are rare, but many of us have encountered them over the years of using a PC. Over time, tools have been developed to solve just this problem, but in this article I will only cover one type of the problem: "Folder with a space at the end that cannot be deleted".
Why isn't the "folder ending with a space" deleted?
The reason why this folder cannot be deleted in Windows is because the folder name is not a valid name. So it has nothing to do with the folder being used by any program; The problem cannot be solved either by restarting the PC or by using the chkdsk tool.
You're probably wondering, if it's not a valid name, how did it appear in first place, or how did Windows allow it. Well, I don't know either but I'm sure some filesystem experts have ideas.
Luckily, the solution I found here worked instantly.
The solution is very simple
You need to change the name of the folder from the command line. For this, we will change the "short name" that Windows Explorer does not show.
1. Open the Start menu, type Cmd and press enter.
2. Using the cd command, navigate to the folder where the stubborn folder is located. For example, type
cd "C:\Users\Zeynel\Music\"
and press Enter.
3. Type dir /x and press Enter. Note here the name of the folder that is not deleted (the folder name will end with ~1).
4. Type the following command to change the name of the folder (type the name you noted instead of foldername~1):
ren foldername~1 newname
5. If the folder is empty, you can use the following command to delete it or delete it from Windows Explorer.
rd newname
Thus, you got rid of the undeletable folder. If our tip worked for you or you have additional notes, you can share them with us in the comments.