Chat freely about anything...

User avatar
By Sirquil
#64294 Stripped everything excepting renaming code.

Code: Select allvoid fileStore()   //If 7th day of week, rename "log.txt" to ("log" + month + day + ".txt") and create new, empty "log.txt"
{

     getDateTime();
     
     
     // rename the file "LOG.TXT"
     String logname;
     logname = "LOG";
     logname += Clock.getMonth(Century);
     logname += Clock.getDate();
     logname += ".TXT";
     SPIFFS.rename("LOG.TXT", logname.c_str());
     
     //For troubleshooting
     Serial.println(logname.c_str());

}


Same result with stripped out code above; no "LOG325.TXT" listed by listFiles function. Serial Monitor shows the filename "LOG325.TXT."

What file are you seeing that is open?

William
User avatar
By Sirquil
#64301 Thank you martinayotte!

I modified the stripped down code; to provide absolute path (root directory).

File was renamed, showing correctly in listFile function!

Code: Select all // rename the file "LOG.TXT"
     String logname;
     logname = "/LOG";
     logname += Clock.getMonth(Century);
     logname += Clock.getDate();
     logname += ".TXT";
     SPIFFS.rename("/LOG.TXT", logname.c_str());
     
     //For troubleshooting
     Serial.println(logname.c_str());


William