When trying to read the file names from an sd card some are being returned with a ~1 and cutting off the full file name.

Initializing SD card...initialization done.
TEST.TXT        402
UNTITL~1        0
HELLOT~1        49
DATALOG.TXT     562288
ALONGN~1        0

Is there any way I get the full file name of each file?

The code for this is from here: https://www.arduino.cc/en/Tutorial/Listfiles

2 Answers 2


That's the way the FAT filesystem works.

On the page you link to there's a link to a page on SDCardNotes.

FAT file systems have a limitation when it comes to naming conventions. You must use the 8.3 format, so that file names look like “NAME001.EXT”, where “NAME001” is an 8 character or fewer string, and “EXT” is a 3 character extension. People commonly use the extensions .TXT and .LOG. It is possible to have a shorter file name (for example, mydata.txt, or time.log), but you cannot use longer file names.

When you wrote the files to the file system you were on an OS that supports longer filenames. When filenames are too long there's an 8.3 name created automatically with chunks of characters removed and replaced with ~.


You have long filenames on your SD card. The SD library is too primitive to know what they are.

I'd suggest switching to FatFS (here is one implementation) which has the option of using long filenames.

  • Nice, didn't know about that. Aug 20, 2018 at 16:48
  • @DaveNewton I'm not sure if that implementation enables long filenames, but the code it wraps certainly supports them.
    – Majenko
    Aug 20, 2018 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.