Now that Drive hosting is going away, we face the task of discovering where its used. One place that it may be used a lot is if you are using the old version of Sites. Unfortunately I am, and unfortunately I am using Drive hosting on pretty much every page. So the first step is to identify
  • which pages are using it
  • which files are being referenced

Following on from that, I may automate the replacement with alternative hosting, but for this post – here’s how to get a report from your site of where you are using Drive hosting. It finds style. If you are hosting gadgets on drive, then the url will be encoded, so it also finds them too.

After running this, you’ll next want to go to Identifying hosted files


There are unsolved (maybe unsolvable) problems with rewriting html to Sites – specifically it can break gadgets and will eliminate any of the deprecated Adsense gadgets (if you still have them on your site), so I’ll need to figure those out (if I can) before publishing an automated update solution.

The damage

Here’ s the damage I need to sort out on this site

753 pages in site

459 pages in site with hosting

2773 hosting changes need to be made

The report

You get 2 reports

One that has a summary of the pages needing attention.

And another that has the detail of all the matches needing attention. The fileName will be populated if the hosting pattern involving a folder and file name is used, instead of the more common file id only.

cUseful library

I’ll be using the cUseful library, specifically this techniques.

Here’s the key for the cUseful library, and it’s also on github, or below.



It starts with the settings, which look like this

The code

Unfortunately, the getAllDescendants() method of sites doesn’t work beyond a certain depth. I didn’t bother to check why, so I’m just recursing through the pages instead, which sweeps up all the pages in the site.

It’s on GitHub, or below, or copy of developing version here. You’ll need the settings namespace at the beginning of this post too and of course the cUseful library reference.

For more like this see Google Apps Scripts Snippets
Why not join our forum, follow the blog or follow me on Twitter to ensure you get updates when they are available.