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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function splitUrlFile(Url) { | |
// remove this line when you incorporate into your script | |
var Url = 'https://drive.google.com/open?id=1ZvhkehvoL99EmmzUsy481givp31odMaO'; | |
// split the Url via the equals sign to break into two | |
var split = Url.split('='); | |
// the file ID is the second part of the split (first part being zero) | |
var uploadID = split[1]; | |
Logger.log('Upload file ID is: ' + uploadID); | |
// instruct DriveApp to open the file by its ID | |
var file = DriveApp.getFileById(uploadID); | |
Logger.log('File is: ' + file); | |
} |
No comments:
Post a Comment