I found a script that will automatically add the file name to the description of all of my files in Google Drive but when I run the script I get the error that DocsList is not defined. I'm new to writing scripts and I've been searching the Google Scripts site but I'm still lost. I'd really appreciate any help that you can offer. Thank you!
function setDescriptionToFolderNames() {
var file;
var filename;
var folders;
var filedescription;
var contents = DocsList.getAllFiles();
// sort ascending. Oldest first, in case of timeout:
contents.sort(function(a,b) {return a.getLastUpdated()-b.getLastUpdated()});
// synchronize folder names of all files (only updates if folders have changed):
for (var i = 0; i < contents.length; i++) {
file = contents[i];
try {
filename = file.getName();
//Logger.log("Checking: " +filename +" ("+file.getLastUpdated()+")");
folders = file.getParents();
// sort by folder name:
folders.sort(function(a, b)
{ return a.getName().localeCompare(b.getName()); }
);
filedescription = "";
for (var f = 0; f < folders.length; f++) {
filedescription = filedescription+folders[f].getName()+" ";
}
if (filedescription != contents[i].getDescription())
{
file.setDescription(filedescription);
Logger.log("Updated: " +filename);
}
} catch(e){ Logger.log("Error: " +filename+" "+e); }
}
};