added check to add only files for which metadat exists; saveMetadata implemented