我找到了一个脚本,它会自动将文件名添加到Google云端硬盘中我所有文件的说明中,但是当我运行脚本时,我收到了未定义DocsList的错误。我是编写脚本的新手,我一直在搜索Google Scripts网站,但我仍然输了。我非常感谢您提供的任何帮助。谢谢!
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); }
}
};
答案 0 :(得分:0)