0
我發現了一個腳本,它會自動將文件名添加到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); }
}
};