Older Windows and DOSs limited filenames to 8 characters, dot, 3 characters - which is known as 8.3 format for obvious reasons. Spaces are
not allowed.
Since Windows 95/98 (can't remember which) Windows now uses long filenames (LFN) which can be up to 256 characters and any dots are your own decision.
To convert a LFN to 8.3 format, take the first 6 characters ignoring spaces
and add ~N onto it - where N is usually 1. If there are multiple files in a folder with the same 6 characters prefix, N increments for each of them in alphabetical order. If it is a file, not a folder, you can then append the .xxx extension.
So, "C

Program Files" would become "C

Progra~1"
If there was also "C

Program Installers", this would become "C

Progra~2".
Ok, enough geeking now...