Delete Image Files /* SD card basic file example This example shows how to create and destroy an SD card file The circuit: SD card attached to SPI bus as follows: ** MOSI - pin 11 ** MISO - pin 12 ** CLK - pin 13 ** CS - pin 4 created Nov 2010 by David A. Mellis modified 9 Apr 2012 by Tom Igoe This example code is in the public domain. */ #include #include #include //int number = 5; File myFile; void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } Serial.print("Initializing SD card..."); if (!SD.begin(10)) { Serial.println("initialization failed!"); return; } Serial.println("initialization done."); //Serial.println("Enter file number to delete up to"); } void loop() { // if (Serial.available()) // { // number = Serial.read(); char filename[13]; for ( int i = 0; i < 1000; i++) { sprintf(filename, "IMAGE%03d.JPG", i); if (! SD.exists(filename)) { Serial.print(filename); Serial.print(" not found"); Serial.println(); } else { SD.remove(filename); Serial.print("deleting "); Serial.print(filename); Serial.println(); } } } //}