【问题标题】:Change PDF file name with names from list with Google Scripts使用 Google 脚本从列表中更改 PDF 文件名
【发布时间】:2020-11-25 02:56:06
【问题描述】:

我有一个新文件名列表,希望应用于谷歌驱动器中的文件列表。

我在 Google 工作表中有 FileID 和相应的新文件名(column1 带有 FilesID,column2 带有新文件名)

我发现的所有解决方案都与将 Old-name 重命名为 New-name 有关。 我正在寻找一种使用 FileID

重命名谷歌驱动器文件的方法

脚本会是什么样子?非常感谢!

【问题讨论】:

  • 我必须为我糟糕的英语水平道歉。我可以问你关于你的问题吗? 1. 什么是a listI have a list of new filenames that like to be applied to a list of files in google drive.。不幸的是,我无法想象它。我为此道歉。 2. 能否提供您当前的剧本以及您的剧本的当前期数?

标签: google-apps-script google-sheets rename file-rename batch-rename


【解决方案1】:
function changenames() {
  const ss=SpreadsheetApp.getActive();
  const sh=ss.getActiveSheet();
  const dt=sh.getRange(2,1,sh.getLastRow()-1,2).getValues();
  dt.forEach(function(r){DriveApp.getFileById(r[0]).setName(r[1])});
}

【讨论】:

  • 这似乎只对第一行进行。
  • 我不小心把getLastColumn()而不是getLastRow()
  • 现在完美运行。谢谢!
猜你喜欢
  • 1970-01-01
  • 2021-12-17
  • 2022-01-26
  • 1970-01-01
  • 1970-01-01
  • 2014-07-29
  • 2020-01-07
  • 2022-12-07
  • 1970-01-01
相关资源
最近更新 更多