admin管理员组文章数量:1203210
I am trying to create a code that will allow me to grab the file information in a given folder, specifically, file names and file links. Additionally, I would like to create download links for each file in the subsequent columns.
I successfully got a code to work that will list the folder contents, but I am having a hard time getting it to do the second step of creating the download link.
I tried to use the link created in the listFolderContents Function in my bulk upload spreadsheet for Pinterest, but I received an error message after my upload saying it couldn't download any of the files, so I really need the modified download link. The folder is set to where anyone with the link can view the files inside. The files are all png image files. Manually getting download links is not an option.
Here is the code that is working for the first thing. I have included the code for the download link, but it isn't doing anything:
function listFolderContents() {
var foldername = 'Pin Images';
var folderlisting = 'listing of folder ' + foldername + Date ();
var folders = DriveApp.getFoldersByName(foldername)
var folder = folders.next();
var contents = folder.getFiles();
var ss = SpreadsheetApp.create(folderlisting);
var sheet = ss.getActiveSheet();
sheet.appendRow( ['name', 'link'] );
var file;
var name;
var link;
var fileId;
var row;
while(contents.hasNext()) {
file = contents.next();
name = file.getName();
link = file.getUrl();
file.getUrl().split('/edit')[0] + '/export?format=png',
file.getUrl().split('/edit')[0] + '/copy'
sheet.appendRow( [name, link] );
}
}
I have spent hours searching for how to get this to work, looking up different code lines and troubleshooting errors. I am not a coder, but am good at figuring things out. I've hit a wall and don't have time to keep going in circles with this so I would appreciate any input. The code above is not giving errors, but it is not doing what I want.
This is where I found the code for the download link:
/
Here is the link for the spreadsheet that is generated when I run the code:
本文标签: directoryList Google Drive Folder Contents and Convert to Download LinksStack Overflow
版权声明:本文标题:directory - List Google Drive Folder Contents and Convert to Download Links - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738632191a2103812.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论