So I asked for help a while back building a .xls converter, and it worked great, until now it suddenly isn't working and it's giving me this error: SyntaxError: Unexpected identifier (line 11, file "DeleteFiles"). I looked through the code and I did not spot a syntax error. Any help in solving this would be appreciated.
function XLSConvert() {
var files = DriveApp.searchFiles("title contains '.xls' and parents in 'File_ID'");
var destinationFolderId = "File_ID";
var existingFileNames = getFilesInFolder(destinationFolderId);
while (files.hasNext()) {
var xFile = files.next();
var name = xFile.getName();
try {
if (!existingFileNames[name] && (name.indexOf('.xls') > -1)) {
var ID = xFile.getId();
var xBlob = xFile.getBlob();
var newFile = {
title: name,
key: ID,
'parents': [{
"id": destinationFolderId
}]
}
file = Drive.Files.insert(newFile, xBlob, {
convert: true
});
}
} catch (error) {
console.error("Error with file " + name + ": " + error);
}
}
function getFilesInFolder(folderId) {
var folderId = "File_ID";
var folder = DriveApp.getFolderById(folderId);
var filesIterator = folder.getFiles();
var files = {};
while (filesIterator.hasNext()) {
var file = filesIterator.next();
files[file.getName()] = true;
}
return files;
}
}