Reputation: 9907
I'm trying to automate the process of creating a shortcut/link to a Google file as one would manually do by right-clicking on a file and seeing the below screen and clicking "Add shortcut to Drive"
Looking through Google's Documentation on file
object shows no actionable methods of this feature, only pulls (i.e. getTargetId()
, etc).
I'm pretty sure this isn't available but I thought I'd throw it out there and see if anyone had any ideas. I see a couple posts using some external API's and firefox which isn't what I'm trying to do.
If I were to guess what code such code would look like, it would be something like this....
function makeSomeFileLink(){
var theFolder = DriveApp.getFolderById("wdflasdjflaskdjfklsadjflk")
var aFile = DriveApp.getFileById("1VjOkMPBDr???????????qkZqPCQWOvBbIt_6GawA");
var myNewBookMark = aFile.makeShortCutAndPutInInThisFolder(theFolder);
}
Obviously, that last row of code is problematic (i.e. I made it up), I'm just trying to illustrate what I'm looking for.
Upvotes: 1
Views: 524
Reputation: 201358
When you want to create a shortcut of the file aFile
to the folder of theFolder
, how about the following modified script?
function makeSomeFileLink(){
var theFolder = DriveApp.getFolderById("wdflasdjflaskdjfklsadjflk");
var aFile = DriveApp.getFileById("1VjOkMPBDr???????????qkZqPCQWOvBbIt_6GawA");
DriveApp.createShortcut(aFile.getId()).moveTo(theFolder);
}
"1VjOkMPBDr???????????qkZqPCQWOvBbIt_6GawA"
to createShortcut
.Upvotes: 1