Create list of files in a Google Drive folder (2020)
Create a spreadsheet of all files in a Google Drive folder with this simple, open source web app. Subfolders included, if you wish.
I like using Google Drive. It captures the essence of Google’s approach to its cloud services: It just works. It is fast, reliable and easy to use because everything but the core functionality has been stripped away.
The downside of that approach can be seen when trying to get some basic information like the number of files inside a folder. Why would anyone consider that feature redundant, I wonder?
Well, wonder no more, fellow users of the internet. From now on, you only need to launch listAllFilesInFolder, grant permissions and enter the name of a folder, or start from the root folder by default. All files within that folder will then be listed in a new spreadsheet. If you do not want to include subfolders, just tick the box.
Let’s say you want to sort your list of files by size. Just open the spreadsheet and identify the column containing the properties you want to sort by (with file size, it should be column G). Click on the downwards arrow next to the column title and select Sort sheet A → Z (or vice versa). Done!
You will find a number of sample scripts on the web that will list all files in a folder to a spreadsheet. The only problem with these code snippets is that they handle each file individually, making the whole process very slow. With some help, I came up with a solution that reads the files into cache and then saves all of them at the same time. As a result, the execution time is drastically reduced and the script handles 5,000+ files (non-recursively) without any error.
If the contents of your folder have changed and you want to recreate the list, simply run the Google Apps Script again.
When using listAllFilesInFolder, none of your personal data is ever collected by, used by, or shared with any third parties. You don’t have to trust me on that, please have a look at the source code and feel free to use, share and modify my code.
To do its job, listAllFilesInFolder requires permission to view and manage the files in your Google Drive and permission to view and manage your spreadsheets in Google Drive. You can revoke these permissions at any time if you no longer want to use the app.