List of google drive folders/files- google script

List of google drive folders/files- google script

List of my successful experiments in digital world :

Enlist names of google drive folder in spreadsheet

Link code for google script : https://goo.gl/qjMtj2

Code is given below. (replace my drive with name of your folder)

 

// replace your-folder below with the folder for which you want a listing
function listFolderContents() {
var foldername = ‘my drive‘;
var folderlisting = ‘listing of folder ‘ + foldername;

var folders = DriveApp.getFoldersByName(foldername)
var folder = folders.next();
var contents = folder.getFiles();

var ss = SpreadsheetApp.create(folderlisting);
var sheet = ss.getActiveSheet();
sheet.appendRow( [‘name’, ‘link’] );

var file;
var name;
var link;
var row;
while(contents.hasNext()) {
file = contents.next();
name = file.getName();
link = file.getUrl();
sheet.appendRow( [name, link] );
}
};

 

Place this script and allow google drive for permission. You will be able to save them in automatic spreadsheet in google drive parent folder. Example of my drive test (for files list) given below. You can replace circled areas according to your need- i.e. name of folder, and whether you need to enlist files names only or folder names only. (This script doesn’t work on hybrid, i.e. both file and folder names, so arrange them in drive accordingly. And ya, ignore cursor pipe sign preceding parenthesis.;-)

 

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.