So I have found many posts that cover how to incrementally name files on an SD card, but I cannot seem to get it to work. Below is what I have been using. I have a tried a few different ways, but all seem to leave me with no way to actually see if the file on the SD card already exists. Currently, what happens is that it always recreates the original file (DATA_000.csv). I am not writing to any special directory, just the root. What I want to do is see if the file exists, and then name a new one incrementally. Any help is appreciated.
Not sure if it makes a difference, but I am doing raw write to the SD.
PaulS, here is more of the code. It is just a small chunk from my sketch, but I think I have included all of the necessary elements relating to this problem:
when I start to run the code provided, if I have a clean SD card that has just been formatted, the file ends up getting created successfully. When I do not format the card before hand (which means DATA_000.CSV exists prior to starting the code) the code is not accurately determining that DATA_000.csv already exists. The results of the code above are:
“Searching for DATA_000.csv
Chosen Name: DATA_000.csv
Card Initialized.
Creating: DATA_000.csv…File Already Exists…File Re-created…”
Well I feel pretty silly at the moment. Thanks Pete for that bit of guidance. The reason it was not working is because I was trying to access the card before initializing it =). Now it works like a charm!