So far I have a code to get files from folder on Google Drive and create a list on Google sheet as
function getFiles() {
//get value from A1 of every sheet
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheetsCount = ss.getNumSheets();
var sheets = ss.getSheets();
var rangeHeader = [];
var range = [];
var value = [];
var files = [];
// for every sheet
for (var i = 1; i < sheetsCount; i++) {
value.push(sheets[i].getRange("A1").getValue()); //get cell A1
}
// Get files from folder
for (var i = 0; i < value.length; i++) { // For all the id on the main sheet
if (value[i] != "") {
sheets[i + 1].appendRow(["File Name", "URL", "Last Updated", "File Type", "Description"]);
files = DriveApp.getFolderById(value[i]).getFiles();
while (files.hasNext()) { // While there is files
var file = files.next(); // Look on the next file
var Name = file.getName();
var url = file.getUrl();
var date = file.getLastUpdated();
var type = file.getMimeType();
var des = file.getDescription();
sheet[i + 1].appendRow(Name, url, date, type, des);
}
}
}
}
I got a result perfectly on the sheet like this
and then I create a function to update a list by delete a value on column A:E and run getFiles function again
BUT when I add value to another column like this
the header row[File Name,url,Last updated,..] move to the 4th row of the sheet,but I want it to append on the 2nd row everytime I run the function.
and I added the value to that column because it could have another information that I'll add it manually in the future.
So,I would like to ask how can I set value or appendRow to the specific row(2nd row) /column A to E on my script? thanks.

