How to get List of Files with Size from Google Drive Folder and Save into Excel Sheet

  Рет қаралды 25,230

TechBrothersIT

TechBrothersIT

Күн бұрын

How to get List of Files with Size from Google Drive Folder and Save into Excel Sheet, in this video we are going to learn How to get List of Files with Size from Google Drive Folder and Save into Excel Sheet.
Script:
function listFolderContents() {
var foldername = 'Final Logos'; // provide the name of Folder from which you want to get the list of files
var ListOfFiles = 'ListOfFiles_' + foldername;
var folders = DriveApp.getFoldersByName(foldername)
var folder = folders.next();
var contents = folder.getFiles();
var ss = SpreadsheetApp.create(ListOfFiles);
var sheet = ss.getActiveSheet();
sheet.appendRow( ['name', 'link','sizeInMB'] );
var var_file;
var var_name;
var var_link;
var var_size;
while(contents.hasNext()) {
var_file = contents.next();
var_name = var_file.getName();
var_link = var_file.getUrl();
var_size=var_file.getSize()/1024.0/1024.0;
sheet.appendRow( [var_name, var_link,var_size] );
}
};
#ExcelSheet #ExcelTricks #GoogleDrive

Пікірлер: 52
@bobmcconnell3123
@bobmcconnell3123 7 ай бұрын
This is brilliant, simple and exactly what I needed. I had never done App Scripting before and I don't know if I'm ready to be a coder yet but this one saved me hours and hours of time on a project. I thank you very much for taking the time to make a great post. BRAVO!
@TechBrothersIT
@TechBrothersIT 7 ай бұрын
Thank you for leaving detailed and nice comments!!Glad to hear that it was helpful
@ernestachenbach4283
@ernestachenbach4283 5 ай бұрын
Worked perfectly. Could have been a 2 minute tutorial, though - but thank you!
@FJ-gt6qw
@FJ-gt6qw Жыл бұрын
Thank you for sharing this!!! Really easy to understand. I want to include parent folders though plus their subfolders, what changes in the code should be done? Thank you. Really appreciate it. :)
@helenekruger5807
@helenekruger5807 Жыл бұрын
Thanks so much! A brilliant script and just what I was looking for!
@tomekleddo8537
@tomekleddo8537 2 жыл бұрын
It's working, chief! However I had to modify slightly the code so it loads the list to the current file (and, of course, in order to clear anteriorly the active sheet every time as it is triggered periodically). Cheers 👍 Code: function listFolderContents() { var foldername = 'YourFolderName'; // provide the name of Folder from which you want to get the list of files var ListOfFiles = 'ListOfFiles_' + foldername; var folders = DriveApp.getFoldersByName(foldername) var folder = folders.next(); var contents = folder.getFiles(); SpreadsheetApp.getActiveSheet().clear(); var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet() sheet.appendRow( ['name', 'link','sizeInMB'] ); var var_file; var var_name; var var_link; var var_size; while(contents.hasNext()) { var_file = contents.next(); var_name = var_file.getName(); var_link = var_file.getUrl(); var_size=var_file.getSize()/1024.0/1024.0; sheet.appendRow( [var_name, var_link,var_size] ); } };
@user-mc8cj3ls6m
@user-mc8cj3ls6m Жыл бұрын
thats exactly what i want to do, do you mind sharing the code?
@tomekleddo8537
@tomekleddo8537 Жыл бұрын
@@user-mc8cj3ls6m function listFolderContents() { var foldername = 'YourFolderName'; // provide the name of Folder from which you want to get the list of files var ListOfFiles = 'ListOfFiles_' + foldername; var folders = DriveApp.getFoldersByName(foldername) var folder = folders.next(); var contents = folder.getFiles(); SpreadsheetApp.getActiveSheet().clear(); var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet() sheet.appendRow( ['name', 'link','sizeInMB'] ); var var_file; var var_name; var var_link; var var_size; while(contents.hasNext()) { var_file = contents.next(); var_name = var_file.getName(); var_link = var_file.getUrl(); var_size=var_file.getSize()/1024.0/1024.0; sheet.appendRow( [var_name, var_link,var_size] ); } };
@balkiszaitoun3051
@balkiszaitoun3051 Жыл бұрын
TypeError: Cannot read properties of null (reading 'clear')
@fairikius
@fairikius Жыл бұрын
WONDERFUL!
@gezegeninsani
@gezegeninsani 2 жыл бұрын
dude thats useful tool. thanks for sharing.
@Handlervideos
@Handlervideos Жыл бұрын
Thanks a bunch, that helped me a lot
@alexarockman3999
@alexarockman3999 Жыл бұрын
This is wonderful, thank you!!
@user-du4tq4tu7j
@user-du4tq4tu7j Жыл бұрын
Do you have this version for shared drive?
@JonathanAdjei
@JonathanAdjei 2 жыл бұрын
Nice work.. thanks!
@cvhaugn
@cvhaugn Жыл бұрын
Hi, I really appreciate this but I have zero knowledge in coding. I just followed as instructed: copy paste the code in App Script, provided the folder name save and run but I am always getting "Error An unknown error has occurred, please try again later." How can I trace what I'm missing? Thank you.
@augustusgoldfinger
@augustusgoldfinger 2 жыл бұрын
Outstanding work friend
@lic.enriquesanchezgonzalez9649
@lic.enriquesanchezgonzalez9649 Жыл бұрын
Thanks so much for the help! This has been useful for complete files, but now I've come up with an obstacle. Sometimes I search for a specific phrase, so only the files with that content appear, and next I want to get the filenames of that filtered list. Could you please suggest any option for this?
@brighnquisitive6217
@brighnquisitive6217 2 жыл бұрын
well done mein freund
@vanthanhduong
@vanthanhduong Жыл бұрын
Thank you
@jenniferprice7494
@jenniferprice7494 Жыл бұрын
Thank you so much! First one I found that worked :)
@ofirronen
@ofirronen 2 жыл бұрын
Hi, it works but not in subfolders....do you know how to make it work for google drive folder with a few subfolders? Thanks!
@moshiblum4664
@moshiblum4664 Жыл бұрын
Thank you, amazing work! 1. I'm Interested in knowing how to get this works for subfolders too. 2. what will happen if I have the same folder names on the drive? will it take both, or just the first one?
@Sunkaless
@Sunkaless Жыл бұрын
@@moshiblum4664 Hey! 8 months later but what the heck, maybe this helps someone else. By the code attached to the video, if two files have the same name, the code only catches the first one it find. Either just rename one of the folders (temporarily if you want to swtich back later), or if you have the same problem as me where you don't own the folder, I've reworked the code so you can specify the parent folder: function listFolderContents() { var parentFolderName = 'writeYourParentFolderNameHere'; // Name of the parent folder var subFolderName = 'writeYourSubFolderNameHere; // Name of the subfolder you're interested in var ListOfFiles = 'ListOfFiles_' + parentFolderName; // Get the parent folder var parentFolders = DriveApp.getFoldersByName(parentFolderName); var parentFolder = parentFolders.next(); // Get all folders with the specified name within the parent folder var subfolders = parentFolder.getFoldersByName(subFolderName); // Iterate over each subfolder and retrieve its contents while (subfolders.hasNext()) { var folder = subfolders.next(); var contents = folder.getFiles(); var ss = SpreadsheetApp.create(ListOfFiles); var sheet = ss.getActiveSheet(); sheet.appendRow(['name', 'link', 'sizeInMB']); var var_file; var var_name; var var_link; var var_size; // Process the files within the subfolder while (contents.hasNext()) { var_file = contents.next(); var_name = var_file.getName(); var_link = var_file.getUrl(); var_size = var_file.getSize() / 1024.0 / 1024.0; sheet.appendRow([var_name, var_link, var_size]); } } } Big thanks to @TechBrothersIT for the original code, helped a bunch!
@HelderSilva-zi4hs
@HelderSilva-zi4hs Жыл бұрын
Hi, Thank you for sharing such an amazing script, this is going to save a lot of time making links for files on my G Drive, but I'm having a problem with the timer limit from the App Script, I have so many files (around 16.000) that I can't create files within the 6 minutes limit that the App Script has, is there a way to bypass that?
@ridhofuadin6248
@ridhofuadin6248 Жыл бұрын
is there a way to get the list of files in drive contain more than 1000 data??
@pertevdural4513
@pertevdural4513 4 ай бұрын
is it possible to list only text files and total number of pages in an sheet? folder name, file name, file type, file page number, file size MB)
@AndreasLenski-ni9mh
@AndreasLenski-ni9mh 2 ай бұрын
Does it work with Shared Folders as well? I get an error: "Exception: Cannot retrieve the next object: iterator has reached the end."
@shibayanbiswas7806
@shibayanbiswas7806 2 ай бұрын
This code is great but it is not working if there is any sub folder in the drive. Is there any solution for it?
@marcoa9944
@marcoa9944 Жыл бұрын
Hey I used the code it worked great but how do I update it when I add more items to the drive folder?
@demimasa-gb7uc
@demimasa-gb7uc Жыл бұрын
question, how to get length videos? what code do we have to use?
@rudroroy1054
@rudroroy1054 2 жыл бұрын
What is the language used to create the script?
@miquelvillartamartinez6855
@miquelvillartamartinez6855 Жыл бұрын
Not working if there are folders with same name. How to handle then? And how to look recursively? Any idea?
@bhavanilakshmipathy6113
@bhavanilakshmipathy6113 Жыл бұрын
The google spread sheet is showing only the headers. Am I doing something wrong?
@kimberlywilliams1606
@kimberlywilliams1606 Жыл бұрын
Will this update automatically when a new file or folder is added?
@Lonewolf-
@Lonewolf- Жыл бұрын
Nope you have to re run it
@Gidon-w5z
@Gidon-w5z Жыл бұрын
Hi, is there a way to list all files of subfolders in 1 folder ?
@maureenmallach5019
@maureenmallach5019 Жыл бұрын
Not sure if you were looking for the same thing I was, but I need a list of all Folder Names that existed in a Shared Drive, vs. Files Names. I tweaked the code to below and it worked like a charm. To be clear, this will ONLY give you the Folders Names in the Parent Folder. Any Files that are in the folder as well are not included. function listFolderContents() { var foldername = 'Clients'; // provide the name of Folder from which you want to get the list of files var ListOfFiles = 'ListOfFiles_' + foldername; var folders = DriveApp.getFoldersByName(foldername) var folder = folders.next(); var contents = folder.getFiles(); var ss = SpreadsheetApp.create(ListOfFiles); var sheet = ss.getActiveSheet(); sheet.appendRow( ['name', 'link','sizeInMB'] ); var var_file; var var_name; var var_link; var var_size; while(contents.hasNext()) { var_file = contents.next(); var_name = var_file.getName(); var_link = var_file.getUrl(); var_size=var_file.getSize()/1024.0/1024.0; sheet.appendRow( [var_name, var_link,var_size] ); } };
@thomvillas
@thomvillas Жыл бұрын
I have a way: Step 1: open the google drive, show the list folder in google drive. Step 2: scrolling capture the screen Step 3: Trim the picture have just capture step 4: use web changing image to excel file
@RyguyThaFlyguy
@RyguyThaFlyguy Жыл бұрын
what about get thumbnail of an image
@stephanieodchigue595
@stephanieodchigue595 2 жыл бұрын
Hi! Can you use this for a shared Google drive?
@TechBrothersIT
@TechBrothersIT 2 жыл бұрын
I have not tried. not sure
@adityakishore3674
@adityakishore3674 Жыл бұрын
I did try it in a shared dirve and it worked
@Lonewolf-
@Lonewolf- Жыл бұрын
As long as you can see a file from you account you can do it
@owkprasanthkumar7292
@owkprasanthkumar7292 2 жыл бұрын
Can you please share the script as was mentioned on the video?
@TechBrothersIT
@TechBrothersIT 2 жыл бұрын
Script is added in the Description, please take look, Thanks For Your Comment.
@johnschimandle9506
@johnschimandle9506 Жыл бұрын
It worked but was not recursive so it did not traverse the folder hierarchy that was inside the folder. Did anyone take the time to make this a recursive algorithm?
@Lonewolf-
@Lonewolf- Жыл бұрын
The too comment has a reply in which he has given the for code for this check that out
@CrynogarTM
@CrynogarTM Жыл бұрын
I killed that script by having 160.222.333.111 Files in my Google Drive. 2238 GB of Data
@Lonewolf-
@Lonewolf- Жыл бұрын
That's crazy
@enriquerochamatus
@enriquerochamatus Жыл бұрын
ooops.... Houston we have a problem: Google is blocking the app since it's trying "to access sensitive info" This app is blocked This app tried to access sensitive info in your Google Account. To keep your account safe, Google blocked this access.
@Lonewolf-
@Lonewolf- Жыл бұрын
Did you try to share the folder
Google Apps Script - Google Drive Tutorial, Files, Folders, Copy Files, DriveApp, Iterator - Part 15
29:31
Learn Google Sheets & Excel Spreadsheets
Рет қаралды 131 М.
Touching Act of Kindness Brings Hope to the Homeless #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 18 МЛН
So Cute 🥰
00:17
dednahype
Рет қаралды 46 МЛН
Секрет фокусника! #shorts
00:15
Роман Magic
Рет қаралды 82 МЛН
هذه الحلوى قد تقتلني 😱🍬
00:22
Cool Tool SHORTS Arabic
Рет қаралды 97 МЛН
List all Files with Each Download Link Google Drive + Google Sheet
8:30
Technology Simplicity
Рет қаралды 12 М.
Split One Google Sheet into Multiple Sheets based on Column Value
26:09
Learn Google Sheets & Excel Spreadsheets
Рет қаралды 89 М.
68. Mendapatkan link file atau gambar dari Google Drive di AppSheet
11:46
Rename Files Uploaded through Google Forms Automatically
9:33
Digital Inspiration
Рет қаралды 9 М.
How to combine AppSheet with Apps Script - Video tutorial
11:14
Google Workspace Developers
Рет қаралды 40 М.
Quickly creating a list of files in a folder
3:44
Matt Lanham
Рет қаралды 352 М.
[2023] Organizing Shared Drives on Google | Creating Groups and Permissions
8:51
itGenius 🤓 Biz Tech Experts
Рет қаралды 45 М.
List All Files and Folders in Gdrive (Google script)
12:49
Touching Act of Kindness Brings Hope to the Homeless #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 18 МЛН