<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>http://s-and-j.co.uk/wiki/index.php?action=history&amp;feed=atom&amp;title=Google_Apps_Script</id>
	<title>Google Apps Script - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://s-and-j.co.uk/wiki/index.php?action=history&amp;feed=atom&amp;title=Google_Apps_Script"/>
	<link rel="alternate" type="text/html" href="http://s-and-j.co.uk/wiki/index.php?title=Google_Apps_Script&amp;action=history"/>
	<updated>2026-09-18T13:53:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>http://s-and-j.co.uk/wiki/index.php?title=Google_Apps_Script&amp;diff=296&amp;oldid=prev</id>
		<title>Simon: Added &#039;code&#039; delimiters</title>
		<link rel="alternate" type="text/html" href="http://s-and-j.co.uk/wiki/index.php?title=Google_Apps_Script&amp;diff=296&amp;oldid=prev"/>
		<updated>2022-10-26T06:46:54Z</updated>

		<summary type="html">&lt;p&gt;Added &amp;#039;code&amp;#039; delimiters&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 07:46, 26 October 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l3&quot;&gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Here is a useful script for plodding through a Google Drive and listing the documents therein, and its sub-folders.  You will not find another script like it because this one works.  The documentation on how to work out the path of a file is wrong, as is much of the advice online on how to do it.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Here is a useful script for plodding through a Google Drive and listing the documents therein, and its sub-folders.  You will not find another script like it because this one works.  The documentation on how to work out the path of a file is wrong, as is much of the advice online on how to do it.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;function ListNamedFilesandFolders() {&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;function ListNamedFilesandFolders() {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   /* Adapted from Code written by @hubgit https://gist.github.com/hubgit/3755293&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   /* Adapted from Code written by @hubgit https://gist.github.com/hubgit/3755293&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   Updated since DocsList is deprecated  https://ctrlq.org/code/19854-list-files-in-google-drive-folder&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   Updated since DocsList is deprecated  https://ctrlq.org/code/19854-list-files-in-google-drive-folder&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l106&quot;&gt;Line 106:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 106:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Simon</name></author>
	</entry>
	<entry>
		<id>http://s-and-j.co.uk/wiki/index.php?title=Google_Apps_Script&amp;diff=295&amp;oldid=prev</id>
		<title>Simon: Created page</title>
		<link rel="alternate" type="text/html" href="http://s-and-j.co.uk/wiki/index.php?title=Google_Apps_Script&amp;diff=295&amp;oldid=prev"/>
		<updated>2022-10-26T06:44:23Z</updated>

		<summary type="html">&lt;p&gt;Created page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Google Scripts stop executing after 30 minutes.  I have not found the setting to increase that.&lt;br /&gt;
&lt;br /&gt;
Here is a useful script for plodding through a Google Drive and listing the documents therein, and its sub-folders.  You will not find another script like it because this one works.  The documentation on how to work out the path of a file is wrong, as is much of the advice online on how to do it.&lt;br /&gt;
&lt;br /&gt;
function ListNamedFilesandFolders() {&lt;br /&gt;
  /* Adapted from Code written by @hubgit https://gist.github.com/hubgit/3755293&lt;br /&gt;
  Updated since DocsList is deprecated  https://ctrlq.org/code/19854-list-files-in-google-drive-folder&lt;br /&gt;
  */&lt;br /&gt;
&lt;br /&gt;
  // List all files and sub-folders in a single folder on Google Drive&lt;br /&gt;
  &lt;br /&gt;
  // declare the folder name&lt;br /&gt;
  var foldername = &amp;#039;PUT_FOLDER_NAME_HERE&amp;#039;;&lt;br /&gt;
  &lt;br /&gt;
  // declare this sheet&lt;br /&gt;
  var sheet = SpreadsheetApp.getActiveSheet();&lt;br /&gt;
  // clear any existing contents&lt;br /&gt;
  sheet.clear();&lt;br /&gt;
  // append a header row&lt;br /&gt;
  // sheet.appendRow([&amp;quot;Folder&amp;quot;,&amp;quot;Name&amp;quot;, &amp;quot;Date Last Updated&amp;quot;, &amp;quot;Size&amp;quot;, &amp;quot;URL&amp;quot;, &amp;quot;ID&amp;quot;, &amp;quot;Description&amp;quot;, &amp;quot;Type&amp;quot;, &amp;quot;Owner&amp;quot;, &amp;quot;Owner2&amp;quot;, &amp;quot;Owner3&amp;quot;, &amp;quot;Path&amp;quot;, &amp;quot;Created&amp;quot;]);&lt;br /&gt;
     sheet.appendRow([         &amp;quot;Name&amp;quot;, &amp;quot;Date Last Updated&amp;quot;,                                     &amp;quot;Type&amp;quot;,                              &amp;quot;Path&amp;quot;, &amp;quot;Created&amp;quot;]);&lt;br /&gt;
&lt;br /&gt;
  // getFoldersByName = Gets a collection of all folders in the user&amp;#039;s Drive that have the given name.&lt;br /&gt;
  // folders is a &amp;quot;Folder Iterator&amp;quot; but there is only one unique folder name called, so it has only one value (next)&lt;br /&gt;
  var folders = DriveApp.getFoldersByName(foldername);&lt;br /&gt;
  var foldersnext = folders.next();&lt;br /&gt;
  // Logger.log(&amp;quot;THE FOLDER IS &amp;quot;+foldersnext);// DEBUG&lt;br /&gt;
&lt;br /&gt;
  //Initiate recursive function&lt;br /&gt;
  listFilesAndSubfolders(foldersnext, foldername);  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function listFilesAndSubfolders(folder, path) {&lt;br /&gt;
  listFiles(folder, path);&lt;br /&gt;
  var subfolders = folder.getFolders();&lt;br /&gt;
&lt;br /&gt;
  while (subfolders.hasNext()) {&lt;br /&gt;
    var mysubfolders = subfolders.next();&lt;br /&gt;
    var mysubfolderName = mysubfolders.getName(); &lt;br /&gt;
    path = path + &amp;quot;/&amp;quot; + mysubfolderName;&lt;br /&gt;
    listFilesAndSubfolders(mysubfolders, path);    &lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function listFiles(foldersnext, path) {&lt;br /&gt;
  var data = [];&lt;br /&gt;
  var sheet = SpreadsheetApp.getActiveSheet();&lt;br /&gt;
&lt;br /&gt;
  // list files in this folder&lt;br /&gt;
  // myfiles is a File Iterator&lt;br /&gt;
  var myfiles = foldersnext.getFiles();&lt;br /&gt;
  // Logger.log(&amp;quot;FILES IN THIS FOLDER&amp;quot;); DEBUG&lt;br /&gt;
  var lastFAllParents = &amp;quot;zzz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  // loop through files in this folder&lt;br /&gt;
  while (myfiles.hasNext()) {&lt;br /&gt;
    var myfile = myfiles.next();&lt;br /&gt;
    var fname = myfile.getName();&lt;br /&gt;
    var fdate = myfile.getLastUpdated(); &lt;br /&gt;
    // speedo  var fsize = myfile.getSize();&lt;br /&gt;
    // speedo  var furl = myfile.getUrl();&lt;br /&gt;
    // speedo  var fid = myfile.getId();&lt;br /&gt;
    // speedo  var fdesc = myfile.getDescription();&lt;br /&gt;
    var ftype = myfile.getMimeType();&lt;br /&gt;
    // speedo  var fowner = myfile.getOwner();&lt;br /&gt;
    // speedo  var fowner2 = fowner.getName();&lt;br /&gt;
    // speedo  var fowner3 = fowner.getEmail();&lt;br /&gt;
    var fAllParents = myfile.getParents();&lt;br /&gt;
    if ( fAllParents != lastFAllParents) {&lt;br /&gt;
      lastFAllParents = fAllParents;&lt;br /&gt;
      var fpath = &amp;quot;&amp;quot;&lt;br /&gt;
      while ( fAllParents.hasNext()) {&lt;br /&gt;
        var fNextFolder = fAllParents.next();&lt;br /&gt;
        var fNextFolderName = fNextFolder.getName();&lt;br /&gt;
        fpath = fNextFolderName + &amp;quot;/&amp;quot; + fpath;&lt;br /&gt;
        fAllParents = fNextFolder.getParents();&lt;br /&gt;
        // speedo  debugger;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // speedo  debugger;&lt;br /&gt;
   &lt;br /&gt;
    var fcreated = myfile.getDateCreated();&lt;br /&gt;
    //Logger.log(&amp;quot;File Name is &amp;quot;+myfile.getName()); //Logger.log(&amp;quot;Date is &amp;quot;+myfile.getLastUpdated()); //Logger.log(&amp;quot;Size is &amp;quot;+myfile.getSize());&lt;br /&gt;
    //Logger.log(&amp;quot;URL is &amp;quot;+myfile.getUrl()); //Logger.log(&amp;quot;ID is &amp;quot;+myfile.getId()); //Logger.log(&amp;quot;Description is &amp;quot;+myfile.getDescription());&lt;br /&gt;
    //Logger.log(&amp;quot;File Type is &amp;quot;+myfile.getMimeType());&lt;br /&gt;
&lt;br /&gt;
    // Populate the array for this file&lt;br /&gt;
    data = [ &lt;br /&gt;
      path,&lt;br /&gt;
      fname,&lt;br /&gt;
      fdate,&lt;br /&gt;
      // speedo  fsize,&lt;br /&gt;
      // speedo  furl,&lt;br /&gt;
      // speedo  fid,&lt;br /&gt;
      // speedo  fdesc,&lt;br /&gt;
      ftype,&lt;br /&gt;
      // speedo  fowner,&lt;br /&gt;
      // speedo  fowner2,&lt;br /&gt;
      // speedo  fowner3,&lt;br /&gt;
      fpath,&lt;br /&gt;
      fcreated&lt;br /&gt;
    ];&lt;br /&gt;
    //Logger.log(&amp;quot;data = &amp;quot;+data); //DEBUG&lt;br /&gt;
    sheet.appendRow(data);&lt;br /&gt;
  } // Completes listing of the files in the named folder&lt;br /&gt;
&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Simon</name></author>
	</entry>
</feed>