Add shortcut for file on Drive with script

50 views
Skip to first unread message

Mark Anthony Amezquita

unread,
Mar 29, 2020, 1:20:36 AM3/29/20
to Google Apps Script Community
  A shortcut for a file on Drive can be added using the Add Shortcut to Drive menu function, but is there a way to do this same thing in a Google Script? So far I haven't found anything with Google Search. I would like to be able to add a shortcut for a file located in one directory and have the shortcut to this file added in another directory. Is this possible? I'm relatively new to coding Google scripts and any assistance would be appreciated. Thanks

 Mark

Romain Vialard

unread,
Mar 29, 2020, 3:31:29 AM3/29/20
to Google Apps Script Community
Yes, it's possible.
This isn't yet available in the DriveApp service of Apps Script. Instead you'll need to enable the Drive Advanced Service in your Apps Script project.

Here's how to enable Advanced Services:

After that, you can use the standard Google Drive API (v2), which has been updated to interact with shortcuts.

Basically a shortcut in Drive is a file with a specific MIME type (application/vnd.google-apps.shortcut). You will need to provide the name of your shortcut + shortcutDetails/targetId to indicate the ID of your original file.

Mark Anthony Amezquita

unread,
Mar 29, 2020, 4:59:15 PM3/29/20
to Google Apps Script Community
Thank you for the insight. I will check out the links you indicated.

 Mark

jmarc D'andria

unread,
Jun 16, 2020, 1:46:55 PM6/16/20
to Google Apps Script Community
Bonjour Romain, 

J'essaye de créer ce fameux raccourci également, j'ai bien activer, Drive Api, ds les ressources et services avancés de script.
et j'ai tjrs ce message de retour en erreur " drive is not defined " , correspondants à ma ligne "drive.file.create".

une idée ??? merci d'avance

Romain Vialard

unread,
Jun 18, 2020, 3:56:35 AM6/18/20
to Google Apps Script Community
Bonjour,

Il suffit d'activer le service avancé + l'accès à l'api Drive si vous avez lié votre script à un projet GCP spécifique.
Si, après avoir éventuellement rechargé le projet Apps Script dans votre navigateur web, drive est toujours undefined, je conseillerais de désactiver / réactiver le service avancé. Si pas plus de succès, éventuellement recommencer depuis un nouveau projet Apps Script...

iBO • App Service

unread,
Aug 20, 2020, 10:19:56 AM8/20/20
to google-apps-sc...@googlegroups.com
Just to keep you updated on the findings, while we try to compensate for the loss, that we have to deal with because "addFile" and "addFolder" are deprecated for "shortcuts".

1. A Shortcut shows to a user, even though the user does not have access to the source, users will see the shortcut, although the do not have access to the file, just because they have access to the folder 

2. To avoid irritation one has to redesign the entire process that has been established for years within a short period of time. Yet one can not replace labels with shortcuts, the concepts to not relate to each other

3.This was not the only hurdle - fundamental changes were applied to the means for deploying apps script. 

Does anybody know who is responsible for this in person? Check if he is bribed by Microsoft for creating such a mess.



iBO • App Service

unread,
Aug 20, 2020, 10:31:16 AM8/20/20
to google-apps-sc...@googlegroups.com
In case you delete a file, remember to find all shortcuts to delete them as well. Any function for that?
--


Reply all
Reply to author
Forward
0 new messages