0

I'm trying to write a script which let's users upload files to a specific folder. They would give the URL of the file they upload in a form (the directory link is available in the form where they should upload files). How can i get the file ID from the URL? The next step would be to create a folder that matches the rowID of the submitted form entry and move the file in that folder, set permissions etc. I can create folders but have no idea how to get the fileid from the url.

4

1 回答 1

0

文件 ID 是 URL 的一部分。只需剥离 id 字符串之前和之后的部分

var url = 'https://docs.google.com/a/some.domain/file/d/0B0RPFf8VgdL4N2IzN2UyOTItYTfkYy00Y2QwLWL4MWYtOGRiMjQ2OTM5YjUx/edit?usp=sharing';
var fileId = url.replace(/.*\/d\//, '').replace(/\/.*/,  '');
var fileName = DriveApp.getFileById(fileId).getName();
于 2013-05-28T12:04:09.513 回答