Creating a file, then pulling it's Id for use in tdfileid

78 views
Skip to first unread message

Christon Pierce

unread,
Feb 26, 2019, 10:53:34 AM2/26/19
to GAM for G Suite
I'm hoping to script a regular report, that I can schedule every week as a batch file. What I'm trying to do, and can't figure out if it's possible, is to create a sheets file at the beginning of the script, then run a bunch of print commands and have each command use todrive to send the output to a separate sheet in the sheets file I created. The problem I'm running into is after I create the file using
gam user *username' create drivefile *specifiedfilename* mimetype gsheet parentname *folder*
if I want to print to that file using the todrive options, I need the file id, and I can't find a way to pull that info back out and use it in the print command. Can anyone help?

Ross Scroggs

unread,
Feb 26, 2019, 11:03:42 AM2/26/19
to google-ap...@googlegroups.com
Christon,

$ gam user testuser1 create drivefile drivefilename NewestSheet mimetype gsheet parentname "Top Folder"

Getting all Drive Files/Folders that match query ('me' in owners and mimeType = 'application/vnd.google-apps.folder' and title = 'Top Folder' and trashed = false) for test...@rdschool.org

Got 1 Drive File/Folder for test...@rdschool.org...

User: test...@rdschool.org, File: NewestSheet(1gf9U5K-LeXkxsV8lVOSIOqq1od7pxtSS-zLh4ACcFJw), Created


The ID is in the output.


You can get it later as well by looking up the name.


$ gam user testuser1 show fileinfo name "NewestSheet" id

Getting all Drive Files/Folders that match query ('me' in owners and title = 'NewestSheet') for test...@rdschool.org

Got 1 Drive File/Folder for test...@rdschool.org...

User: test...@rdschool.org, Show 1 Drive File/Folder

  File: NewestSheet (1gf9U5K-LeXkxsV8lVOSIOqq1od7pxtSS-zLh4ACcFJw)

    id: 1gf9U5K-LeXkxsV8lVOSIOqq1od7pxtSS-zLh4ACcFJw

$ gam user testuser1 print filelist query "name= 'NewestSheet'" id

Getting all Drive Files/Folders that match query ('me' in owners and title= 'NewestSheet') for test...@rdschool.org

Got 1 Drive File/Folder for test...@rdschool.org...

Owner,id

test...@rdschool.org,1gf9U5K-LeXkxsV8lVOSIOqq1od7pxtSS-zLh4ACcFJw


Unfortunately, todrive can only create a new spreadsheet file and name the sheet or update an existing spreadsheet file by replacing its contents with the new data and naming the sheet.

It can not add a new sheet to an existing spreadsheet file.


Ross


--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/f48a1cae-750c-492f-a242-d74ba5d56a63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

+KimNilsson

unread,
Mar 4, 2019, 4:13:56 AM3/4/19
to GAM for G Suite
Christon,

I can also add that we were looking into this with a coder for keeping a Sheets file updated with status of Chrome devices, but quickly decided against having the script create new tabs in an existing Sheet. With lots of data, that Sheet will be hard to use only after a few cycles.

Instead it's better to create new dated files with the new data.

/Kim

On Tuesday, 26 February 2019 17:03:42 UTC+1, Ross Scroggs wrote:
...
Reply all
Reply to author
Forward
0 new messages