Created
July 29, 2019 21:50
-
-
Save Yuri-M-Dias/6aecd406500db8a6c3725f3508a5a521 to your computer and use it in GitHub Desktop.
Copy Drive url files from a Google Sheets to another folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getIdFromUrl(url) { return url.match(/[-\w]{25,}/); } | |
function sendFilesToFolder() { | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
var startRow = 2; // First row of data to process | |
var numRows = 60; // Number of rows to process | |
// row x column, row x column | |
var startCol = 1 | |
var endCol = 29 | |
var dataRange = sheet.getRange(startRow, 10, numRows, 40); | |
var destFolder = DriveApp.createFolder("ArquivosWETEOrganizados"); | |
var data = dataRange.getValues(); | |
for (var i = 0; i < data.length; ++i) { | |
var row = data[i]; | |
var authorEmail = row[3]; | |
var authorName = row[0]; | |
var articleURL = row[18]; | |
if(articleURL == "") continue; | |
var articleID = getIdFromUrl(articleURL)[0]; | |
var ArticleFile = DriveApp.getFileById(articleID) | |
var authURL = row[19]; | |
var authID = getIdFromUrl(authURL)[0]; | |
var AuthFile = DriveApp.getFileById(authID) | |
var articleCopy = ArticleFile.makeCopy("[Artigo] " + authorName, destFolder) | |
var authCopy = AuthFile.makeCopy("[Autorização] " + authorName, destFolder) | |
Logger.log('Copied for %s', authorName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment