I'm trying to rename a .pdf file in a google drive folder with Google App Script.
function findFilesInFolder() {
var childrenData = Drive.Children.list('XXXXXXX')
var children = childrenData.items;
//loops through the children and gets the name of each one
for (var i = 0; i < children.length; i++){
var id = children[i].id;
var file = Drive.Files.get(id);
file.setName('testname');
}
}
Looking at this doc https://developers.google.com/apps-script/reference/drive/file#setName(String) setName is the right method to use.
fileis not valid. Log theidAfter this line:var id = children[i].id;Add:Logger.log('id: ' + id)Run the code, then from the View menu, choose Logs. If there is noidor if there is no file with thatidthen the variablefilemay not be a valid file. - Alan WellssetNamesomewhere else? - Alan Wells