vatolin

Q: How to repair and avoid corrupted filenames on FAT32 USB sticks?

When I use an USB stick both on Windows and on OSX some filenames on the stick are changing/corrupted. Originally the filenames are like doc19941720151116122616.pdf. But suddenly the name of one, two of appr. a hundred files are like DOC199~1.PDF. I have figured out, that such changes/corruptions doesn't occur if OSX is prevented to create the typical invisible files/folders like .fseventd .DS_Store etc. For this purpose I am using the application Blue Harvest.

 

I've read that the filename DOC199~1.PDF ist the real name of the file, which is stored in the file allocation table (FAT), but the filenme doc19941720151116122616.pdf is stored in the file itself. But when I open the file DOC199~1.PDF with Textedit.app I do not find this filename.

 

How can I find and repair the original filename of DOC199~1.PDF?

 

And how can I prevent the USB stick from OSX typical invisible files/folders, so that such files are never written on the stick, independently whether Blue Harvest is installed on a Mac or not? There should be a script or something else on the stick which prevents OSX from doing its job.

 

Thanks in advance for your support!

 

Kind regards, Friedrich

Posted on Dec 2, 2015 4:40 AM

Close

Q: How to repair and avoid corrupted filenames on FAT32 USB sticks?

  • All replies
  • Helpful answers

  • by Kurt Lang,

    Kurt Lang Kurt Lang Dec 2, 2015 7:04 AM in response to vatolin
    Level 8 (37,939 points)
    Mac OS X
    Dec 2, 2015 7:04 AM in response to vatolin

    It's not file corruption, it's intentional.

     

    The real name of the file is the long name you gave it - doc19941720151116122616.pdf . A short name is saved at the same time using the first 6 characters and appending ~1. This is for backward compatibility with the original DOS naming convention of 8.3 (no more than 8 characters before the period, and no more than 3 after it). This is how the Windows Joliet file system is designed to work.

     

    If you were to save another long file name in the same folder with the same first 6 characters, the short name would become DOC199~2.PDF. It will keep doing this while truncating even more of the first characters, so you would eventually get something like DOC1~236.PDF (if you had 236 files that all started with the same characters in the same folder). But again, these are the short names. Your long names are still there.

     

    You should be able to get the original names back if you take the drive to a Windows computer where it can read the long name. Getting them over to the Mac in non-truncated form may be a bit of work. The only way I can think to do it is to use a newer file system on the flash drive. The easiest one to try first that doesn't require the purchase of anything is to first copy all of the files off to your Windows computer so that you can see all of the long file names you expect. With all of the data safely on the Windows computer's hard drive, reformat the USB drive as exFAT from Windows. Copy all of the data back to the USB drive and test on the Mac to see if you get what you expect.

     

    If not, then you'll have to use a more up-to-date drive format and purchase software for one computer or the other. That would be to either format the USB drive as NTFS in Windows and then install Paragon NTFS for Mac on your Mac (of course), or do it the other way around - format the drive on your Mac as Mac OS Extended (Journaled) and install Paragon HFS+ for Windows.

  • by vatolin,

    vatolin vatolin Dec 2, 2015 7:50 AM in response to Kurt Lang
    Level 1 (4 points)
    Mac OS X
    Dec 2, 2015 7:50 AM in response to Kurt Lang

    Kurt Lang wrote:

    [...] reformat the USB drive as exFAT from Windows. […] use a more up-to-date drive format.

     

    It's unpreventable to use the FAT32 file format. Because the stick must work not only with Windows and OSX but also with an Kyocera TASKalfa 3051ci multifunction device. The only file format that works with all those gadgets is FAT32.

     

    Kurt Lang wrote:

    You should be able to get the original names back if you take the drive to a Windows computer where it can read the long name.

     

    Hmm. I afraid, this won't work. Because when I connect the stick with the Kyocera, it shows in the file list only the short name of the corrupted files.

  • by Kurt Lang,

    Kurt Lang Kurt Lang Dec 2, 2015 8:04 AM in response to vatolin
    Level 8 (37,939 points)
    Mac OS X
    Dec 2, 2015 8:04 AM in response to vatolin

    Then the problem is the Kyocera device. It is not reading the long names when they overlap in the same folder and will only show you the short names.

     

    To repeat, there is no corruption. That is how FAT32/Joliet works, when things are working as they should.

     

    There's always the chance though that the file table on the flash drive is damaged. So go to your Windows computer and copy everything off. Reformat the drive as FAT32. Copy the files back and try it in the Kyocera device again. If it still won't produce the long file names you should see, then your only options are to a) see if there's a firmware update for the Kyocera device that fixes this issue, or b) get a new device that works the way it's supposed to.

     

    Edit: I do see this is a rather large, and I would presume expensive office device, so replacing it certainly wouldn't be at the top of your list. You may want to contact Kyocera about the issue and see that they say. exFAT is an extension of the FAT32 format, so you may still be able to try that and see if it works. You would only lose about 15 of your time to try. Worst that could happen is you have to reformat the drive back to FAT32 and copy the saved files on the Windows computer back to it.

  • by rccharles,

    rccharles rccharles Dec 2, 2015 2:26 PM in response to vatolin
    Level 6 (8,506 points)
    Classic Mac OS
    Dec 2, 2015 2:26 PM in response to vatolin

    I've read that the filename DOC199~1.PDF ist the real name of the file, which is stored in the file allocation table (FAT), but the filenme doc19941720151116122616.pdf is stored in the file itself.

     

    The long names are stored in the file allocation table fat too.  Somehow, the long names are chained together in adjacent fat entries.

     

    You might have better luck limiting you names to 8.3.

     

    R

  • by John Lockwood,

    John Lockwood John Lockwood Dec 3, 2015 3:04 AM in response to vatolin
    Level 6 (9,349 points)
    Servers Enterprise
    Dec 3, 2015 3:04 AM in response to vatolin

    Different operating systems have different rules regarding file names. This applies to both the length of file names as mentioned by Kurt Lang, and also applies to the legally allowed characters in file names.

     

    See this for some good guidance - OS X: Cross-platform filename best practices and conventions - Apple Support

     

    The most important characters to avoid in file names are : (colon), \ (backslash) and / (forward slash) but as per the Apple article there are others it is also a good idea to avoid. I find a lot of people make the mistake of using forward slashes to include a date in a file name e.g. my-file-11/11/15.doc

     

    With regards to the length of a file name, apart from some very old software not being able to cope with longer than the 8.3 format if a filename does contain a character the system cannot cope with this will typically also result in a truncated 8.3 format file name being shown even if otherwise it could read a longer file name. Also if the file is in a series of folders and the total length of all the names of all the folders and the filename itself is longer than 256 characters then again this will result in the name being truncated to an 8.3 format.

     

    Other than replacing the Kyocera with something more modern, or if your lucky getting its software upgraded you need to make sure you use names that offer the best chance of not breaking the rules and thereby being converted to an 8.3 format. We use Konica-Minolta MFP devices and do not see this problem.