Link to home
Start Free TrialLog in
Avatar of PeterFrb
PeterFrbFlag for United States of America

asked on

Using "Files Cabinet" or creating virtual link to Google Drive

I have tried solving the same problem using three different methods, and I've failed both times.

I am trying to convert the contents of Google Drive (Folders, Files, File Sizes) into a data format.  I will list both things I tried and where the problem lies:

Method 1: I researched and found an app called "Files Cabinet", part of a suite made by a company called "Awesome Table".  Apparently, I have succeeded in downloading the program, because I can log into the Awesome Table website (see https://awesome-table.com/) using my credentials.  The advertising says that Awesome Table is an addin to Excel, and I can use it to create a hierarchal tree of my target.  However, I dont see Awesome Table as an Addin choice within Excel, and whenever I try opening an Excel file within the Awesome table interface, I get some kind of error.  Seems like a good idea, can't get it to work.  

Method 2: I also installed both "Files Cabinet" and "Excel" on my Smart Phone, but my research tells me that you can't have addins on smart phones, only PC's and Mac's.  

Method 3: If I were able to create a virtual link on my hard drive to a folder in my Google drive, that would satisfy the requirement, as I have direct visibility to my local drive.  Other research revealed that when clicking on Google-Drive folder and then clicking <Shift><Z>, I can create a "Symlink", which I expected to be a virtual folder in my hard drive.  I have used this functionality before, when working with SharePoint, and I am hoping for that functionality here.  (See https://www.bustercollings.com/blog/2014/06/14/how-to-copy-a-file-or-folder-in-google-drive-create-a-symbolic-link-symlink/).  

I will happily accept recommendations that gains me traction on any of these methods.  Thank you, ~ Peter Ferber
Avatar of Bill Prew
Bill Prew

I am trying to convert the contents of Google Drive (Folders, Files, File Sizes) into a data format.

I don't think I understand exactly what you are trying to accomplish, can you expand more on this statement and what your goal is?

That being said, do you have the Google Drive for Windows installed?


If so then when you configured that you could choose to sync a local copy of the Google Drive to your computer.  And when you do that it creates a folder locally to store a copy of the files in.  Changes made to that location are automatically pushed to the cloud, and vice versa, so it is kept up to date.

I took the defaults for this and it created that local folder in "C:\Users\xxxxxxxx\Google Drive" where xxxxxxxx is my Windows user id.

You should be able to see where that folder is located from the taskbar icon if you can't find it.  Then you can use it to get access to the files in the Drive.

But I may not understand what you really want...


»bp
Avatar of PeterFrb

ASKER

Hi, Bill, and thanks for your lengthy reply.  I tuned out there for a bit of time, sorry.

I just downloaded Google Drive for Windows, and it looks like it may be that for which I am looking.  It sounds like it creates a virtual drive on a PC and replicates the same folder and file structure onto the PC, without actually taking up space on the hard drive.  I actually found a code block that comes quite close to that which I'm seeking.  I found this code block on a search, and I apologize for losing site of the one who did the publishing.  This is a code block within the Sheets program in Google Drive, and it leverages the fact that it has a spreadsheet host to supply that spreadsheet with the data it collects.  Here is that code:

function Run_LIstNamedFilesAndFolders() {
/* Adapted from Code written by @hubgit https://gist.github.com/hubgit/3755293
Updated since DocsList is deprecated  https://ctrlq.org/code/19854-list-files-in-google-drive-folder
*/


  // List all files and sub-folders in a single folder on Google Drive
  // declare the folder name
  //var foldername = '_Full Job Folder';

  // declare this sheet
  var sheet = SpreadsheetApp.getActiveSheet();
  // clear any existing contents
  sheet.clear();
  // append a header row
  sheet.appendRow(["Folder","Name", "Date Last Updated", "Size", "URL", "ID", "Description", "Type"]);


  // getFoldersByName = Gets a collection of all folders in the user's Drive that have the given name.
  // folders is a "Folder Iterator" but there is only one unique folder name called, so it has only one value (next)
  var folders = DriveApp.getFoldersByName(foldername);
  var foldersnext = folders.next();
  // Logger.log("THE FOLDER IS "+foldersnext);// DEBUG

  // declare an array to push data into the spreadsheet
  var data = [];

  // list files in this folder
  // myfiles is a File Iterator
  var myfiles = foldersnext.getFiles();
  ListNamedFilesandFolders('_Full Job Folder');
}

function ListNamedFilesandFolders(foldername) {
///* Adapted from Code written by @hubgit https://gist.github.com/hubgit/3755293
//Updated since DocsList is deprecated  https://ctrlq.org/code/19854-list-files-in-google-drive-folder
//*/
//
//
//  // List all files and sub-folders in a single folder on Google Drive
//  // declare the folder name
//  //var foldername = '_Full Job Folder';
//
//  // declare this sheet
//  var sheet = SpreadsheetApp.getActiveSheet();
//  // clear any existing contents
//  sheet.clear();
//  // append a header row
//  sheet.appendRow(["Folder","Name", "Date Last Updated", "Size", "URL", "ID", "Description", "Type"]);
//
//
//  // getFoldersByName = Gets a collection of all folders in the user's Drive that have the given name.
//  // folders is a "Folder Iterator" but there is only one unique folder name called, so it has only one value (next)
//  var folders = DriveApp.getFoldersByName(foldername);
//  var foldersnext = folders.next();
//  // Logger.log("THE FOLDER IS "+foldersnext);// DEBUG
//
//  // declare an array to push data into the spreadsheet
//  var data = [];
//
//  // list files in this folder
//  // myfiles is a File Iterator
//  var myfiles = foldersnext.getFiles();

  // Logger.log("FILES IN THIS FOLDER"); DEBUG

  // loop through files in this folder
  while (myfiles.hasNext()) {
    var myfile = myfiles.next();
    var fname = myfile.getName();
    var fdate = myfile.getLastUpdated(); 
    var fsize = myfile.getSize();
    var furl = myfile.getUrl();
    var fid = myfile.getId();
    var fdesc = myfile.getDescription();
    var ftype = myfile.getMimeType();
    //Logger.log("File Name is "+myfile.getName()); //Logger.log("Date is "+myfile.getLastUpdated()); //Logger.log("Size is "+myfile.getSize());
    //Logger.log("URL is "+myfile.getUrl()); //Logger.log("ID is "+myfile.getId()); //Logger.log("Description is "+myfile.getDescription());
    //Logger.log("File Type is "+myfile.getMimeType());

    // Populate the array for this file
    data = [ 
      foldersnext,
      fname,
      fdate,
      fsize,
      furl,
      fid,
      fdesc,
      ftype
    ];
    //Logger.log("data = "+data); //DEBUG
    sheet.appendRow(data);
  } // Completes listing of the files in the named folder

  // Now get the subfolder
  // subfolders is a Folder Iterator
  var subfolders = foldersnext.getFolders();
  //Logger.log("THE SUBFOLDER(S) ARE"); DEBUG HEADING

  // now start a loop on the SubFolder list
  while (subfolders.hasNext()) {
    var subfolderdata = [];
    var mysubfolders = subfolders.next();
    var mysubfolder = mysubfolders.getName();  
    //Logger.log("Subfolder name:"+mysubfolder); //DEBUG

    // Get the files
    // mysubfiles is a File Iterator
    var mysubfiles = mysubfolders.getFiles();
    //Logger.log("FILES IN THIS FOLDER"); //DEBUG HEADING

    // now start a loop on the files in the subfolder
    while (mysubfiles.hasNext()) {
      var smyfile = mysubfiles.next();
      var sfname =  smyfile.getName();
      var sfdate =  smyfile.getLastUpdated(); 
      var sfsize =  smyfile.getSize();
      var sfurl =  smyfile.getUrl();
      var sfid =  smyfile.getId();
      var sfdesc =  smyfile.getDescription();
      var sftype =  smyfile.getMimeType();
      //Logger.log("Subfolder is "+foldersnext+"/"+mysubfolder); 
      //Logger.log("File Name is "+ smyfile.getName()); Logger.log("Date is "+ smyfile.getLastUpdated()); Logger.log("Size is "+ smyfile.getSize());
      //Logger.log("URL is "+ smyfile.getUrl()); Logger.log("ID is "+ smyfile.getId()); Logger.log("Description is "+ smyfile.getDescription());Logger.log("File Type is "+ smyfile.getMimeType());
      subfolderdata = [ 
        (foldersnext+"/"+mysubfolder),
        sfname,
        sfdate,
        sfsize,
        sfurl,
        sfid,
        sfdesc,
        sftype
      ];
      //Logger.log("subfolderdata = "+subfolderdata);
      sheet.appendRow(subfolderdata);
    }
  }
}

Open in new window

Really, the only thing missing is recursion, to capture all the subfolders, regardless of how deep it runs.  This program captures the files in one level of nested subfolders.  The end product is a Google Drive sheet with folder and file name, but no file size, which is something I would definitely add.  If you get this to run, you will see what I was envisioning.  Thank you, ~ Peter Ferber
I haven't worked with Google's scripting language so not much help there.

In my local Google Drives folder I see some files (like .XLS) that are a copy of the actual file, while others (.GSHEET) seem to be a reference to a cloud "url" of the file.  So it looks like there are different rules depending on the type of file, or it's origin, etc.  I'm not knowledgeable on that.

As far as the folder recursion, it would depend on that code you found, and the properties of the objects exposed.  The way it talks about the folder iterator though, it doesn't sound like it is "populated" based on the hierarchical structure of the folders, which would be critical to a recursive approach, which I might be able to help with if you get a little further.  It's something I've done frequently in VBA and VBS on Windows for local files / folders.


»bp
@Peter,

Are you all set with this now, or do you need more help?  If all set, could you please close it out now.  If you need help with the question close process take a look at:



»bp
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.