I have a very old car radio that can play music from USB fash drives when they are formatted in FAT16 or FAT32, but it sorts files by the short 8.3 file name, not by the long file name.
I want to play audiobooks that are divided into multiple files, but Windows sometimes generates f***ed up 8.3 file names.
Here's an example of the output of dir /x of a folder that contains Internet1.mp3 to Internet7.mp3:
                                  Short          Long
30.12.2020  15:59  2.186.859   INTERN~1.MP3   Internet1.mp3
30.12.2020  15:59  2.507.643   INTERN~2.MP3   Internet2.mp3
30.12.2020  15:59  2.423.319   INTERN~3.MP3   Internet3.mp3
30.12.2020  15:59  2.110.163   INTERN~4.MP3   Internet4.mp3
30.12.2020  15:59  2.007.345   IN1FAB~1.MP3   Internet5.mp3
30.12.2020  15:59  2.921.422   IN64EF~1.MP3   Internet6.mp3
30.12.2020  15:59  3.290.689   INB914~1.MP3   Internet7.mp3
As you can see, the files Internet5.mp3 to Internet7.mp3 will be played before Internet1.mp3 to Internet4.mp3 since they have the random short file names. Some of my audiobooks are divided into more than 100 parts, so i'd like to have a script (Batch, Powershell, Python, whatever) that automatically sets the short file name to something usable, I.e. INT1.MP3 to INT7.MP3 There is no problem regarding which folder to play. The long file names contain an ascending numer (here 1 to 7) that gives away the correct order of the files.
                        
You can use this to change all files matching the
Internet*pattern toINTxxxxxYou can change
ls Internet*to justlsto ignore the prefix and rename all files in the folderUpdate:
Unfortunately you can set short names for files on NTFS partitions, as it's the restriction right from the
SetFileShortName()Win32 APITherefore the only way you can do for a FAT16/32 partition is rename all your files to a short 8.3 name like this
Of course you can also use the
INTxxxxx.MP3format like aboveYou can manually hex edit the partition to set the short names and recalculate the checksums but it'll be fragile unless someone writes a tool to automate all those things
Note that names like
IN1FAB~1.MP3orIN64EF~1.MP3are not random. They're the hash of the file names because it's obvious that theFile~NUMBERpattern doesn't work if there are more than 9 files with that prefix in the folder so something more robust must be used