code: function getUniqueFilename(base, filename) {
      if (!filename) {
          filename = base;
          base = '/';
      }
  
      filename = path.resolve(base, filename);
      var ext = path.extname(filename);
      filename = path.join(path.dirname(filename), path.basename(filename, ext));
  
      var _filename = filename+ext;
  
      var i = 0;
      while (fs.existsSync(filename)) {
          _filename = filename+'_'+i+ext;
          i = i + 1;
      }
  
      return path.relative(base, _filename);
  }
docs: Find a filename available