GAS Folders, Sub Folders and their Files

Google Drive is a wonderful thing, but when it comes to getting at a file with scripts things can get a little quirky. Every file and folder has a unique ID number (28 digits, letters and other marks) which can make it easy to locate it, if you know how. However you can of course have many files, or folders with the same name spread out across your Google Drive, which can create a bit of a problem when trying to find the file or folder. Very often you may have to iterate over “all the folders” in order to find what you want, using names to do this can be problematic.

I find I am routinely needing to grab a list of filenames, file IDs, or file types, and routinely searching the web each time I need to do this, therefore it was about time I tied down the required scripts in one place for reuse. The scripts I have put together will request either a folder name or ID in order to iterate over the files within that folder and return the results to a spreadsheet. The scripts can be used as a base, and edited to suit specific requirements by adding further properties to return, or through the use of if statements to narrow down selected files.

  • You can find the ID of the folder by looking in the url address bar if you have the folder open in Google Drive
  • You can also right click on the folder and then Shareable Link
  • Finding the name should be obvious! – use search in Google Drive to check for folders with the same name. It may be wise to do this occasionally if you use name a lot in your scripts, and to make your folder names unique

In my scripts I have chosen to return the filename, the mime type, the file ID, and to create a download link. I also include a helper script (courtesy of Sandy Good) that presents the mimetype in a more user friendly way. All four folder scripts rely on this. Thanks should also go to Brian P and AD:AM on the google group support forum for their code.

I will add a link to a google sheet which contains all the scripts, just make a copy of it to your own google drive, authorise the scripts and away you go.

Continue reading

Google Sites (Classic) – Embed Live (working) Google Sheet “Range”

This one has been annoying me for a while but I finally arrived at a solution. It is especially usefeul when working inside a G Suite domain, and you wish to share information on a spreadsheet with some selectable cells (e.g. with drop downs) via a classic googlesites page, so for people with the right permissions they can use the functionality of the sheet without causing damage to the underlying data.

The default options and gadgets for presenting a spreadsheet offer too much of the sheet for my liking.

The way to sort this out is to create a web App that can be displayed on the page. The apps script is created on the website (Manage Site > Apps Script), and once the two parts are created inside a project, the app can be deployed and will then show up when added to you page.

So here is what you need to put in your code.gs Continue reading

Encoding for youtube

I can never seem to get it right. These two links offer some respite:

Ffmpeg Wiki

Re-encode the video and stream copy the audio. The output should be a similar quality as the input and will hopefully be a more manageable size.

Same as above, but also re-encode the audio instead of stream copying it:

Create a video with a still image (input.png) and an audio file (audio.ogg):

Jernej Virag

Grab BBC News Videos with a Bash Script

A colleague asked me the other day if I could download a video clip from the BBC News website so that she could use it in her training course (to save having to load up the website and play it “live” from there!)

I said anything is possible 😉  Took me on a little journey but finally found a way without having to resort to any browser plugins or switching to Windows to download a video grabber program. Decided to write a bash script to pull all the elements together too :) Continue reading

Take Screenshot via ssh

A cool little command line or two.

Say you have a remote machine that you can ssh into, it is running an X server, and you want to take a screenshot of what is on screen. You will need imagemagick installed on the remote machine for the import command to work.

1. After you have ssh’d in:

This will save the screenshot to the remote machine’s tmp folder. You will need to scp across to get it!

2. Before ssh’ing

Replace user@remote-host with your details. The image will appear on your PC, you can then save it as required.

Both very cool :)

Master Document in Google Drive using Google Apps Script

Word and LibreOffice can do this as a built-in feature but Sharepoint and Google Drive/Docs can’t. Given that Sharepoint is a nightmare to just use (!) I tackled the problem on Google Drive. What we are seeking to achieve is to have a main or master document that pulls in other documents, correctly formatted to make a full document. This is useful when “writing a book”, or creating a Health and Safety file or Employee Handbook. Once again I can’t take all the credit for a lot of the coding, the initial script to pull in formatted data from other documents is due to Henrique Abreu with additional help from Mogsdad and Serge Insas. Continue reading

Automate Printing of Completed Google Form

I need to write this up before I forget what I did!

This is quite complex and draws on several resources. Why do this? Because in my organisation many have not/cannot move to online systems, we do not have the resources (e.g. tablets/laptops), or what we need is not yet written/ready, so whilst we can easily input data with google forms, we still need a paper copy in order to act on the contents and record actions. In addition this gets the data into a digital format we can work with (on the google sheet), making it easier to work with and interrogate later, without having to input it from the paper form. Continue reading

Digital Signage with Google Slides and Chromium in Kiosk Mode

Another solution to digital signage, this time using Google Slides and Chromium (or Chrome) in Kiosk mode.

I am using the base of a linux install (Crunchbang) and Chromium, but the basics transfer across to Chrome and other OS platforms with some tweaking.

Issues:

  • Kiosk Syntax
  • Fullscreen
  • The Google Slides Toolbar or Transport
  • Web Page Presentation
  • Updating the Slides
  • Sharing the Slides
  • Locking Down if keyboard/touchscreen in use

Am grateful for the work done by Mark Pajak at Bristol Museums on setting up Chrome/Chromium in kiosk mode, and to Google Slides users on the google groups forums and good old StackOverflow for other snippets.

As an overview, one needs to publish the google slides presentation, then pull this into an iframe on a web page. Then call chromium in kiosk mode to load that web page. Once the slides are loaded they will not update with new content unless the call to the slides is reset (page reload) so some html/javascript is required to refresh things. This all may seem a little disjointed at first but be patient, i will put it all together at the end with a workflow and example 😉 Continue reading