转换 google 个电子表格中的最新文件
Convert latest file in google spreadsheets
我需要一些帮助,我有下面的脚本可以将“.xls”文件转换成 google 电子表格,但我需要你始终使用文件夹 A 中的最新文件,我可以别那样做。
function importXLS(){
var folderBId = "ID FOLDER"; // Added // Please set the folder ID of "FolderB".
var files = DriveApp.getFolderById('ID FOLDER').searchFiles('title != "nothing"');
while(files.hasNext()){
var xFile = files.next();
var name = xFile.getName();
if (name.indexOf('.xls')>-1){
var ID = xFile.getId();
var xBlob = xFile.getBlob();
var newFile = {
title : 'backlog'+'_converted',
parents: [{id: folderBId}] // Added
};
file = Drive.Files.insert(newFile, xBlob, {
convert: true
});
}
}
}
文件夹中最近更新的文件
function mostrecentlyupdatedfileinafolder() {
const folder = DriveApp.getFolderById(gobj.globals.testfolderid);
const files = folder.getFiles();
const fa = [];
while(files.hasNext()) {
let file = files.next();
fa.push(file);
}
fa.sort((a,b) => {
return b.getLastUpdated().valueOf() - a.getLastUpdated().valueOf();
});
//let fnA = fa.map(f => f.getName()).flat();
//Logger.log(JSON.stringify(fnA));
return fa[0];
}
我需要一些帮助,我有下面的脚本可以将“.xls”文件转换成 google 电子表格,但我需要你始终使用文件夹 A 中的最新文件,我可以别那样做。
function importXLS(){
var folderBId = "ID FOLDER"; // Added // Please set the folder ID of "FolderB".
var files = DriveApp.getFolderById('ID FOLDER').searchFiles('title != "nothing"');
while(files.hasNext()){
var xFile = files.next();
var name = xFile.getName();
if (name.indexOf('.xls')>-1){
var ID = xFile.getId();
var xBlob = xFile.getBlob();
var newFile = {
title : 'backlog'+'_converted',
parents: [{id: folderBId}] // Added
};
file = Drive.Files.insert(newFile, xBlob, {
convert: true
});
}
}
}
文件夹中最近更新的文件
function mostrecentlyupdatedfileinafolder() {
const folder = DriveApp.getFolderById(gobj.globals.testfolderid);
const files = folder.getFiles();
const fa = [];
while(files.hasNext()) {
let file = files.next();
fa.push(file);
}
fa.sort((a,b) => {
return b.getLastUpdated().valueOf() - a.getLastUpdated().valueOf();
});
//let fnA = fa.map(f => f.getName()).flat();
//Logger.log(JSON.stringify(fnA));
return fa[0];
}