Thursday 27 December 2018

Split file upload Url

The following Google Apps Script code is designed to extract the file ID from a Url of a document that has been uploaded via a Google Form. You can use the function to feed in a Url (typically acquired from a spreadsheet of data), split it to get the ID, then instruct 'DriveApp' to get the file so you can do something with it.

An example Url has been included below for demo purposes only, with 'split' being used to separate the Url via the equals sign (=). The result of this is now 2 components of which the latter is the ID we want (so 1ZvhkehvoL99EmmzUsy481givp31odMaO in this example) so we can assign this to a variable. Finally, we can now use 'getFileById' to open it.

Split Url File Upload.gs

No comments:

Post a Comment