Problem on creating new files using SD library

Hi, I came across a problem on creating new files into SD card using SD library.

What I want to do is every time the device turns on it will create a new file with a unique name in the SD card. So I used Unix time as the name of the file. But it won’t work, nothing will be created in the SD card and I think this may be caused by the length of Unix time which contains 10 numbers, such as 1559836353.csv.
If I use a number with only 8 numbers, such as 12345678.csv, then everything just works well.

Here is my code related to this problem.

#include <SD.h>
#include <DS3231.h>

File mySensorData;
static String filename;

void setup(){
  pinMode(10, OUTPUT);

  filename = String(rtc.getUnixTime(rtc.getTime())) + ".csv";
  // filename = "12345678.csv"; this line will work.
  mySensorData =, FILE_WRITE);

void loop(){
// other functions

So I want to know if there is any solution to this problem or if there are some other methods to create a file with a unique name which only contains less than 8 characters.

Thanks a lot!

I think this may be caused by the length of Unix time which contains 10 numbers

The SD library only supports 8.3 format filenames

Thanks for your help!
Oh, that's so bad...
Do you have any ideas about any other things we can use as a unique name which suits for this situation?
Thank you very much!


Thanks for your reply!

Good idea! I have thought about this. The only flaw about it is that the last 8 digits will run out within about 3 years, which is not a big problem though.

A few minutes ago, I just realized that I could first create a folder using the current month as its name, like 2019-Jun. Then I can use day hours minutes and seconds as the file names, like “ddhhmmss”, which may make more sense to most people.

Thank you so much!