X

Get file id dan file name dari file di google drive

Get file id dan file name dari file di google drive dan insert ke spreadsheet

video

app script

function listFilesInFolder() {
  var folderId = "xxx"; // ganti engan folder id anda
  var folder = DriveApp.getFolderById(folderId);
  var files = folder.getFiles();
  
  var spreadsheetId = "xxx"; // ganti dengan id spreadsheet anda
  var sheetName = "Sheet1"; //ganti dengan nama sheet yg dipilih
  var sheet = SpreadsheetApp.openById(spreadsheetId).getSheetByName(sheetName);
  
  var fileInfo = [];
  while (files.hasNext()) {
    var file = files.next();
    var fileId = file.getId();
    var fileName = file.getName();
    var fileUrl = getFileUrl(fileId);
    var fileDirectLink = getDirectLink(fileId);
    fileInfo.push([fileName, fileId, fileUrl, fileDirectLink]);
  }
  
  sheet.getRange(1, 1, fileInfo.length, 4).setValues(fileInfo);
}

function getFileUrl(fileId) {
  return "https://drive.google.com/file/d/" + fileId + "/view";
}

function getDirectLink(fileId) {
  return "https://drive.google.com/uc?id=" + fileId + "&export=download";
}
adikiss: i'm just an ordinary person | Direktur PT. Adya Global Media | Telegram : <a href="https://t.me/adikiss">t.me/adikiss</a> | Whatsapp : <a href="https://wa.me/6285640206067">wa.me/6285640206067</a> | Facebook : <a href="https://fb.me/adikiswanto">fb.me/adikiswanto</a>
Related Post
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings