Sarija Janardh
Sarija Janardh

Reputation: 65

convert a csv to google sheet and remove the csv file

I have a code that converts a csv file to google sheet from a folder. What I would like to do is remove the csv file after conversion .Planning to make a script that runs each day and convert all the generated csv files to google sheet and remove the csv files with that name. the Code I am using below

function convert_to_googlesheets() {
  var folder = DriveApp.getFolderById('1jxxxxxxxxWfl2yk4xxxxxxxx');
  var files = folder.getFiles();
  while (files.hasNext()) {
    var file = files.next();
    Drive.Files.copy({}, file.getId(), {convert: true});
  }
} 

Upvotes: 1

Views: 197

Answers (1)

Yuri Khristich
Yuri Khristich

Reputation: 14527

Try to add

file.setTrashed(true);

After Drive.Files.copy({}, file.getId(), {convert: true});

Upvotes: 2

Related Questions