I have a code which creates a file then store relevant data. My first purpose was creating then rewriting (delete & write again) with same filename. However, now I have to log different data to analyze them. I do not want to append the new data to old one because they are sound files. So I want to add timestamp to the filename, so I can easily distinguish the records. I was able to do it in Python, but I dont know how to achieve this with ino code. I'm using ESP32 if it is important. Part of my code:

const char filename[] = "/sound.wav";
file = SD.open(filename, FILE_WRITE);

Now as you can see, it creates the file sound.wav, but I want to add a random number or timestamp to this name automatically. Such as sound3534.wav or sound2905192348.wav etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.