Google应用脚本重命名文件无效

时间:2014-06-28 05:18:06

标签: google-apps-script

运行此脚本时,我收到错误消息 TypeError:在对象File中找不到函数setName。 (第8行,文件“代码”)

function rename() {
  var folder = DocsList.getFolder('Folder');
  var files = folder.getFiles();
  for (var i in files) {
    oldName = files[i].getName()
    newName = oldName.replace(/\d+/g, '')
    newName = newName.replace(/\s/g, '');
    files[i].setName(newName)

  }

3 个答案:

答案 0 :(得分:1)

对我来说,我使用的是setName()。

files[i].setName(newName);

答案 1 :(得分:0)

该方法是rename()而不是setName()

files[i].rename(newName)

答案 2 :(得分:0)

WITH case_cte (stageKey, caseNumber) 
  AS (SELECT stageKey, *a complicated case statement* 
      FROM Inventory.Staging WHERE state = @final)
INSERT INTO (itemNumber, itemCode) ' and a lot more columns
SELECT c.CaseNumber, Inventory.ConstructItemCode(c.CaseNumber) ' and a lot more columns
FROM Inventory.Staging a INNER JOIN case_cte c ON a.stageKey = c.stageKey