How to get the free/used space on a SD card and transmit it
As SD.h includes

  #include "utility/SdFat.h"
  #include "utility/SdFatUtil.h" 


or if you use the SDfat library than this function is more efficient than going all over the place:

#include &lt;SdFat.h&gt;

SdFat SD; 

void ShowFreeSpace() {
  // Calculate free space (volume free clusters * blocks per clusters / 2)
  long lFreeKB = SD.vol()-&gt;freeClusterCount();
  lFreeKB *= SD.vol()-&gt;blocksPerCluster()/2;

  // Display free space
  Serial.print("Free space: ");
  Serial.print(lFreeKB);
  Serial.println(" KB");
}