- You'll need to make a spreadsheet.
- Then go to tools>script editor.
- You can cut/paste the script below replacing all of the contents that were put in by default.
- You'll need to add your folder ID where it says THIS_SHOULD_BE_YOUR_FOLDER_ID (leave the quotes).
- Save it.
- Hit the play/run button
- You'll need to give it permission to run when asked.
That should do it. Working example of output here.
/* modified from @hubgit and http://stackoverflow.com/questions/30328636/google-apps-script-count-files-in-folder
for this stackexchange question http://webapps.stackexchange.com/questions/86081/insert-image-from-google-drive-into-google-sheets by @twoodwar
*/
function listFilesInFolder(folderName) {
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Name", "Date", "Size", "URL", "Download", "Description", "Image"]);
//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("THIS_SHOULD_BE_YOUR_FOLDER_ID");
var contents = folder.getFiles();
var cnt = 0;
var file;
while (contents.hasNext()) {
var file = contents.next();
cnt++;
data = [
file.getName(),
file.getDateCreated(),
file.getSize(),
file.getUrl(),
"https://docs.google.com/uc?export=download&confirm=no_antivirus&id=" + file.getId(),
file.getDescription(),
"=image(\"https://docs.google.com/uc?export=download&id=" + file.getId() +"\")",
];
sheet.appendRow(data);
};
};