2014-09-17

Folder name with a space in the end

Problem:
One or two times when I downloaded a torrent, it creates a folder with a blank space in the end in its name. At first I thought it is some kind of mistake from the creator of the torrent, but now I think it is done on purpose.
This folder reacts very strange, you cannot rename or delete it. In my last case, I could enter inside, but open only files with short names, without blanks.

Cause:
The reason for this problem is that the torrent program creates an invalid NTFS entry, following the information in the torrent file. Probably it won't be a big problem on Linux ext3/4.

Solution:
I found some solutions over the Internet. Many people have fought this.

-=Here is how to delete it:=-
http://stackoverflow.com/questions/21072767/windows-7-cant-delete-a-folder-with-a-trailing-space

rd "\\?\C:\holds bad subdir\20120530-04 "


-=Here is how to rename it:=-
http://superuser.com/questions/565334/rename-delete-windows-x64-folder-with-leading-and-trailing-space

rename "\\?\c:\PATH HERE\[ ]1[ ]" "NEW FILE NAME"
or
rename "\\?\c:\PATH HERE\ 1 " "NEW FILE NAME"


-=Some more information from Microsoft (6):=-
https://support.microsoft.com/kb/320081


-=Some more information from ME:=-
I wanted just to rename it, so I can access my files. I used CMD and in the folder one level up the bad one I used the following command:

dir /x

...which gives the 8.3 compatible aliases of the folder names like this:

Now you can just use the rename command, but instead of full directory name - put the alias, like
rename linksf~1 newname

Cheers!