gpt4 book ai didi

google-apps-script - 在 searchFiles Google 脚本中使用变量

转载 作者:行者123 更新时间:2023-12-05 04:09:57 25 4
gpt4 key购买 nike

我有一个第三方程序可以将每日数据提取到 CSV 文件中,文件名以运行日期开头,例如17072017文件名.csv我需要一个单独的电子表格,它将从用户那里输入日期,然后它将搜索驱动器中的文件,直到它与 CSV 文件上的日期匹配。一旦找到我想要的文件,我就可以使用 getFileID() 和 getRange() 从该 CSV 文件中复制各种值。这就是我目前所拥有的(电子表格中的单元格 A2 是用户可以键入他们想要的日期的地方,例如 17072017)。

问题似乎是我无法将日期(每天都会更改)作为 searchFiles() 中的变量传递。这可能吗?这是我目前所拥有的

function myfunction()
{
var inputDate = SpreadsheetApp.getActiveSheet().getRange("A2").getValue();
var files = DriveApp.searchFiles('title contains 'inputDate'');
while (files.hasNext())
{
var file = files.next();
Logger.log(file.getName());
}
}

最佳答案

下面的修改怎么样?

发件人:

var files = DriveApp.searchFiles('title contains 'inputDate'');

收件人:

var files = DriveApp.searchFiles("title contains '" + inputDate + "'");

如果我误解了你的问题,我很抱歉。

关于google-apps-script - 在 searchFiles Google 脚本中使用变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45156245/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com