我试图将Google云端硬盘中的特定文件插入到文件夹中.我还想检查是否有名称的文件夹'testFolder'
:如果是,则将文件插入到现有文件夹,否则创建一个名为'testFolder'
.
这是我到目前为止所提出的,但它总是创建一个名为的新文件夹'testFolder'
(因此用户有10个文件夹'testFolder'
现在命名- 它不会重复使用第一个文件夹).
var copyId = /* the id of the file to copy */;
function InsertFileToFolder() {
var file = DriveApp.getFileById(copyId);
var folder;
if (folderExists() == true){
folder = DriveApp.getFolder("testFolder"); //<-- No such thing in GAS i think?
} else {
folder = DriveApp.createFolder("testFolder");
}
folder.addFile(file);
}
//Check whether folder exists or not
function folderExists() {
var folders = DriveApp.getFolders();
var flag = false;
for(var i = 0; i < folders.length; …
Run Code Online (Sandbox Code Playgroud) 我做了一个脚本,打印出Logger中的当前月份.我认为这可以通过Arrays以更好的方式完成.
这是我到目前为止:
function myFunction() {
var date = new Date();
var mt = date.getMonth();
var currentD
if (mt === 0) {
currentD = "JAN (qty)";
}if (mt === 1) {
currentD = "FEB (qty)";
}if (mt === 2) {
currentD = "MAR (qty)";
}if (mt === 3) {
currentD = "APR (qty)";
}if (mt === 4) {
currentD = "MAJ (qty)";
}if (mt === 5) {
currentD = "JUNI (qty)";
}if (mt === 6) {
currentD = "JULY (qty)";
}if …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Google Apps脚本中的高级日历服务来更改日历中特定事件的colorId.
到目前为止,我已经能够列出并获得事件和我喜欢的事件.所以我有活动的ID.
function getSpecificEvent(){
var calendarId = 'primary';
var eventId = '7h2tbvns2oo4r5gku6ghjfjclk';
var calEvent = Calendar.Events.get(calendarId, eventId);
Logger.log(calEvent);
}
Run Code Online (Sandbox Code Playgroud)
这是我在编辑colorID时尝试的,我使用补丁:
function setEventColor(){
var calendarId = 'primary';
var eventId = '7h2tbvns2oo4r5gku6ghjfjclk';
Calendar.Events.patch(calendarId, eventId).colorId('11');
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,第33行是这一行:
Calendar.Events.patch(calendarId, eventId).colorId
Run Code Online (Sandbox Code Playgroud)