functiononOpen(){varss=SpreadsheetApp.getActiveSpreadsheet();varsearchMenuEntries=[{name:"Create a File List from Folder",functionName:"start"}];ss.addMenu("File List",searchMenuEntries);}functionstart(){varsheet=SpreadsheetApp.getActiveSheet();sheet.clear();//Comment below enable it if you need one sheetsheet.appendRow(["Name","Folder","Type","Date","Size","URL"]);varfolderName=Browser.inputBox("Enter Folder Name (this will destroy the current spreadsheet):");//var folderName = "Safety Subdomain Assets";varfolder=DriveApp.getFoldersByName(folderName);if(folder.hasNext()){processFolder(folder);}else{Browser.msgBox('Folder not found!');}functionprocessFolder(folder){while(folder.hasNext()){varf=folder.next();varcontents=f.getFiles();addFilesToSheet(contents,f);varsubFolder=f.getFolders();processFolder(subFolder);}}functionaddFilesToSheet(files,folder){vardata;varfolderName=folder.getName();//Delete this two lines below if you need one Sheet// sheet.appendRow(["Folder: " + folder]);// sheet.appendRow(["Name", "Folder", "Type", "Date", "Size", "URL" ]);while(files.hasNext()){varfile=files.next();Logger.log(file.getName());sheet.appendRow([file.getName(),folderName,file.getMimeType(),file.getDateCreated(),file.getSize()/1024,file.getUrl()]);}}}
Warp outperforms every other coding agent on the market, and gives you full control over which model you use. Get started now for free, or upgrade and unlock 2.5x AI credits on Warp's paid plans.
I've tried a few scripts to do this, and the code above is by far the best google drive script for recursive listing of folder contents I've seen. Cool to be able to enter a custom folder name (amazingly many others need it entering directly in the code). And to see it completing in real time. Many thanks for posting !
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (1)
I've tried a few scripts to do this, and the code above is by far the best google drive script for recursive listing of folder contents I've seen. Cool to be able to enter a custom folder name (amazingly many others need it entering directly in the code). And to see it completing in real time. Many thanks for posting !