List of Subfolder names and file links in google sheets - script Announcing the arrival of...

Noise in Eigenvalues plot

Does a random sequence of vectors span a Hilbert space?

Adapting the Chinese Remainder Theorem (CRT) for integers to polynomials

Sally's older brother

Is it OK to use the testing sample to compare algorithms?

How to achieve cat-like agility?

Why does BitLocker not use RSA?

Inverse square law not accurate for non-point masses?

Did pre-Columbian Americans know the spherical shape of the Earth?

What is "Lambda" in Heston's original paper on stochastic volatility models?

In musical terms, what properties are varied by the human voice to produce different words / syllables?

What does 丫 mean? 丫是什么意思?

Centre cell vertically in tabularx

Is there a spell that can create a permanent fire?

By what mechanism was the 2017 UK General Election called?

Diophantine equation 3^a+1=3^b+5^c

How to resize main filesystem

Twin's vs. Twins'

My mentor says to set image to Fine instead of RAW — how is this different from JPG?

Should man-made satellites feature an intelligent inverted "cow catcher"?

Random body shuffle every night—can we still function?

Can two people see the same photon?

Was the pager message from Nick Fury to Captain Marvel unnecessary?

3D Masyu - A Die



List of Subfolder names and file links in google sheets - script



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Google Spreadsheet Indirect in a VLookupIs there a command line utility to script uploads to Google Drive and share items?add text (and possibly images) to illustrator via scriptSync with Google Drive and DocsAdding date to the name of multiple files in multiple foldersAutomatically create subfolders by date and move files into subfolder at the end of the dayGoogle Backup and Sync file lock issueGDrive command-line utility - How can I get the ID of a Google Drive file given its “friendly” file name?Script for deduplicating files and folders with a particular suffixI want to push either a TSV file or JSON up to a Google Sheet





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I'm trying to get a Google Sheet list of file links in folders and subfolders which I'm keeping in Google Drive. It should look something like this:



one main folder with a couple of subfolders inside



I was googling and reading forums for a quite a time now but I managed to find only a few script examples and not all of them are working. I found one script which is not too bad as it brings a list of files with links in one folder. but I would like to get a list of files with links in subfolders. Ideally all folder links and item names would be listed in one cell with a separator "|". one of the best script examples I found so far is:



function listFilesInFolder(folderName) {

var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Name", "File-Id"]);


//change the folder ID below to reflect your folder's ID (look in the URL when you're in your folder)
var folder = DriveApp.getFolderById("0ByQ9Zp2ge-pzSjhKdHVWWk0wNnc");
var contents = folder.getFiles();

var cnt = 0;
var file;

while (contents.hasNext()) {
var file = contents.next();
cnt++;

data = [
file.getName(),
file.getId(),
];

sheet.appendRow(data);
};
};


and it brings results in a sheet



enter image description here



It would be much appreciated if anyone could help to get a better version of this code.



p.s.There's also a few bigger scripts I will need in a future which I'm willing to pay for. please message me if you're interested.










share|improve this question
















bumped to the homepage by Community 3 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 1





    You are asking an off-topic question. Please read On-Topic, How do I ask a good question? and What types of questions should I avoid asking?.

    – DavidPostill
    Jul 1 '16 at 11:36


















0















I'm trying to get a Google Sheet list of file links in folders and subfolders which I'm keeping in Google Drive. It should look something like this:



one main folder with a couple of subfolders inside



I was googling and reading forums for a quite a time now but I managed to find only a few script examples and not all of them are working. I found one script which is not too bad as it brings a list of files with links in one folder. but I would like to get a list of files with links in subfolders. Ideally all folder links and item names would be listed in one cell with a separator "|". one of the best script examples I found so far is:



function listFilesInFolder(folderName) {

var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Name", "File-Id"]);


//change the folder ID below to reflect your folder's ID (look in the URL when you're in your folder)
var folder = DriveApp.getFolderById("0ByQ9Zp2ge-pzSjhKdHVWWk0wNnc");
var contents = folder.getFiles();

var cnt = 0;
var file;

while (contents.hasNext()) {
var file = contents.next();
cnt++;

data = [
file.getName(),
file.getId(),
];

sheet.appendRow(data);
};
};


and it brings results in a sheet



enter image description here



It would be much appreciated if anyone could help to get a better version of this code.



p.s.There's also a few bigger scripts I will need in a future which I'm willing to pay for. please message me if you're interested.










share|improve this question
















bumped to the homepage by Community 3 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 1





    You are asking an off-topic question. Please read On-Topic, How do I ask a good question? and What types of questions should I avoid asking?.

    – DavidPostill
    Jul 1 '16 at 11:36














0












0








0








I'm trying to get a Google Sheet list of file links in folders and subfolders which I'm keeping in Google Drive. It should look something like this:



one main folder with a couple of subfolders inside



I was googling and reading forums for a quite a time now but I managed to find only a few script examples and not all of them are working. I found one script which is not too bad as it brings a list of files with links in one folder. but I would like to get a list of files with links in subfolders. Ideally all folder links and item names would be listed in one cell with a separator "|". one of the best script examples I found so far is:



function listFilesInFolder(folderName) {

var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Name", "File-Id"]);


//change the folder ID below to reflect your folder's ID (look in the URL when you're in your folder)
var folder = DriveApp.getFolderById("0ByQ9Zp2ge-pzSjhKdHVWWk0wNnc");
var contents = folder.getFiles();

var cnt = 0;
var file;

while (contents.hasNext()) {
var file = contents.next();
cnt++;

data = [
file.getName(),
file.getId(),
];

sheet.appendRow(data);
};
};


and it brings results in a sheet



enter image description here



It would be much appreciated if anyone could help to get a better version of this code.



p.s.There's also a few bigger scripts I will need in a future which I'm willing to pay for. please message me if you're interested.










share|improve this question
















I'm trying to get a Google Sheet list of file links in folders and subfolders which I'm keeping in Google Drive. It should look something like this:



one main folder with a couple of subfolders inside



I was googling and reading forums for a quite a time now but I managed to find only a few script examples and not all of them are working. I found one script which is not too bad as it brings a list of files with links in one folder. but I would like to get a list of files with links in subfolders. Ideally all folder links and item names would be listed in one cell with a separator "|". one of the best script examples I found so far is:



function listFilesInFolder(folderName) {

var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Name", "File-Id"]);


//change the folder ID below to reflect your folder's ID (look in the URL when you're in your folder)
var folder = DriveApp.getFolderById("0ByQ9Zp2ge-pzSjhKdHVWWk0wNnc");
var contents = folder.getFiles();

var cnt = 0;
var file;

while (contents.hasNext()) {
var file = contents.next();
cnt++;

data = [
file.getName(),
file.getId(),
];

sheet.appendRow(data);
};
};


and it brings results in a sheet



enter image description here



It would be much appreciated if anyone could help to get a better version of this code.



p.s.There's also a few bigger scripts I will need in a future which I'm willing to pay for. please message me if you're interested.







script google-drive links google-spreadsheets g-suite






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 7 '16 at 5:31









3498DB

15.9k114862




15.9k114862










asked Jul 1 '16 at 0:19









JoshJosh

112




112





bumped to the homepage by Community 3 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 3 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.










  • 1





    You are asking an off-topic question. Please read On-Topic, How do I ask a good question? and What types of questions should I avoid asking?.

    – DavidPostill
    Jul 1 '16 at 11:36














  • 1





    You are asking an off-topic question. Please read On-Topic, How do I ask a good question? and What types of questions should I avoid asking?.

    – DavidPostill
    Jul 1 '16 at 11:36








1




1





You are asking an off-topic question. Please read On-Topic, How do I ask a good question? and What types of questions should I avoid asking?.

– DavidPostill
Jul 1 '16 at 11:36





You are asking an off-topic question. Please read On-Topic, How do I ask a good question? and What types of questions should I avoid asking?.

– DavidPostill
Jul 1 '16 at 11:36










1 Answer
1






active

oldest

votes


















0














// replace Guitar_Score below with the folder for which you want a listing with all subfolders
function listFolderContents() {
var foldername = 'Guitar_Score';
// file with this name will be saved in your goolge files
var folderlisting = 'listing of folder ' + foldername;
var ss = SpreadsheetApp.create(folderlisting);
var sheet = ss.getActiveSheet();
var folders = DriveApp.getFoldersByName(foldername)
var folder = folders.next();
//listFilesInFolder(folder, sheet);
traverseFolder(folder, sheet);
};

function traverseFolder(folder, sheet) {
listFilesInFolder(folder, sheet);
var subFolders = folder.getFolders();
while (subFolders.hasNext()) {
traverseFolder(subFolders.next(), sheet);
}
}

function listFilesInFolder(folder, sheet) {
var foldername = folder.getName();
var contents = folder.getFiles();
sheet.appendRow( ['...', foldername] );
while(contents.hasNext()) {
var file = contents.next();
var name = file.getName();
var link = file.getUrl();
sheet.appendRow( [name, link] );
}
}





share|improve this answer


























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1095578%2flist-of-subfolder-names-and-file-links-in-google-sheets-script%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    // replace Guitar_Score below with the folder for which you want a listing with all subfolders
    function listFolderContents() {
    var foldername = 'Guitar_Score';
    // file with this name will be saved in your goolge files
    var folderlisting = 'listing of folder ' + foldername;
    var ss = SpreadsheetApp.create(folderlisting);
    var sheet = ss.getActiveSheet();
    var folders = DriveApp.getFoldersByName(foldername)
    var folder = folders.next();
    //listFilesInFolder(folder, sheet);
    traverseFolder(folder, sheet);
    };

    function traverseFolder(folder, sheet) {
    listFilesInFolder(folder, sheet);
    var subFolders = folder.getFolders();
    while (subFolders.hasNext()) {
    traverseFolder(subFolders.next(), sheet);
    }
    }

    function listFilesInFolder(folder, sheet) {
    var foldername = folder.getName();
    var contents = folder.getFiles();
    sheet.appendRow( ['...', foldername] );
    while(contents.hasNext()) {
    var file = contents.next();
    var name = file.getName();
    var link = file.getUrl();
    sheet.appendRow( [name, link] );
    }
    }





    share|improve this answer






























      0














      // replace Guitar_Score below with the folder for which you want a listing with all subfolders
      function listFolderContents() {
      var foldername = 'Guitar_Score';
      // file with this name will be saved in your goolge files
      var folderlisting = 'listing of folder ' + foldername;
      var ss = SpreadsheetApp.create(folderlisting);
      var sheet = ss.getActiveSheet();
      var folders = DriveApp.getFoldersByName(foldername)
      var folder = folders.next();
      //listFilesInFolder(folder, sheet);
      traverseFolder(folder, sheet);
      };

      function traverseFolder(folder, sheet) {
      listFilesInFolder(folder, sheet);
      var subFolders = folder.getFolders();
      while (subFolders.hasNext()) {
      traverseFolder(subFolders.next(), sheet);
      }
      }

      function listFilesInFolder(folder, sheet) {
      var foldername = folder.getName();
      var contents = folder.getFiles();
      sheet.appendRow( ['...', foldername] );
      while(contents.hasNext()) {
      var file = contents.next();
      var name = file.getName();
      var link = file.getUrl();
      sheet.appendRow( [name, link] );
      }
      }





      share|improve this answer




























        0












        0








        0







        // replace Guitar_Score below with the folder for which you want a listing with all subfolders
        function listFolderContents() {
        var foldername = 'Guitar_Score';
        // file with this name will be saved in your goolge files
        var folderlisting = 'listing of folder ' + foldername;
        var ss = SpreadsheetApp.create(folderlisting);
        var sheet = ss.getActiveSheet();
        var folders = DriveApp.getFoldersByName(foldername)
        var folder = folders.next();
        //listFilesInFolder(folder, sheet);
        traverseFolder(folder, sheet);
        };

        function traverseFolder(folder, sheet) {
        listFilesInFolder(folder, sheet);
        var subFolders = folder.getFolders();
        while (subFolders.hasNext()) {
        traverseFolder(subFolders.next(), sheet);
        }
        }

        function listFilesInFolder(folder, sheet) {
        var foldername = folder.getName();
        var contents = folder.getFiles();
        sheet.appendRow( ['...', foldername] );
        while(contents.hasNext()) {
        var file = contents.next();
        var name = file.getName();
        var link = file.getUrl();
        sheet.appendRow( [name, link] );
        }
        }





        share|improve this answer















        // replace Guitar_Score below with the folder for which you want a listing with all subfolders
        function listFolderContents() {
        var foldername = 'Guitar_Score';
        // file with this name will be saved in your goolge files
        var folderlisting = 'listing of folder ' + foldername;
        var ss = SpreadsheetApp.create(folderlisting);
        var sheet = ss.getActiveSheet();
        var folders = DriveApp.getFoldersByName(foldername)
        var folder = folders.next();
        //listFilesInFolder(folder, sheet);
        traverseFolder(folder, sheet);
        };

        function traverseFolder(folder, sheet) {
        listFilesInFolder(folder, sheet);
        var subFolders = folder.getFolders();
        while (subFolders.hasNext()) {
        traverseFolder(subFolders.next(), sheet);
        }
        }

        function listFilesInFolder(folder, sheet) {
        var foldername = folder.getName();
        var contents = folder.getFiles();
        sheet.appendRow( ['...', foldername] );
        while(contents.hasNext()) {
        var file = contents.next();
        var name = file.getName();
        var link = file.getUrl();
        sheet.appendRow( [name, link] );
        }
        }






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 7 '16 at 5:31









        3498DB

        15.9k114862




        15.9k114862










        answered Nov 4 '16 at 22:56









        Sasha BondSasha Bond

        1113




        1113






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1095578%2flist-of-subfolder-names-and-file-links-in-google-sheets-script%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...

            Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

            VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...