Creating Shortcut on Google Drive using Google Apps Script
This is a sample script for creating a shortcut on Google Drive using Google Apps Script.
Sample script
Before you run the script, please enable Drive API at Advanced Google services.
function createShortcut(targetId, name, folderId) {
const resource = {
shortcutDetails: { targetId: targetId },
title: name,
mimeType: "application/vnd.google-apps.shortcut",
};
if (folderId) resource.parents = [{ id: folderId }];
const shortcut = Drive.Files.insert(resource);
return shortcut.id;
}
// Please run this function.
function main() {
const targetId = "###"; // Please set the ID of target file or folder.
const shortcutName = "###"; // Please set the shortcut name.
const folderId = "###"; // Please set the folder ID for putting the created shortcut.
const id = createShortcut(targetId, shortcutName, folderId);
console.log(id);
}