I have a script to rename files in a Google Drive but it is not working. In particular, I want to erase the last character of the file name and set this new name as the file name.
function re_name() {
var folder = DriveApp.getFolderById("folderId");
var files = folder.getFiles();
var date = new Date("August 29, 2018");
while(files.hasNext()){
var aux = files.next();
if(aux.getDateCreated() == date ){
aux.setName(aux.getName().replace(".s", ""))
}
}
Also, I'm not sure if replace() that exists in java can be used in Google Script.
But even if it is not the case to use replace() I can't seem to make modifications an follows:
aux.setName(aux.getName() + ".f")
Please help to find the mistake or else I would very much appreciate an alternative method.