Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
Google Drive file when upload duplicating same name

When i run a program in google script for upload image from url to drive.program run successful. But i want overwrite the same file in same name not multiple files

This is my code :

function myFunction() {
  var url  ="https://html.com/wp-content/uploads/flamingo.jpg";
  var response = UrlFetchApp.fetch(url);
  console.log(response.getResponseCode());
  var blob=response.getAs('image/jpeg');
  var folder = "1WnbHBPcYd9S4XwXpcYEMX32k********";
  var fileName=decodeURIComponent(url.split("/").pop());
  
  console.log("File named : "+fileName);
  var file=DriveApp.getFolderById(folder).createFile(blob);
  // Set the name to the created file after creating it!
  file.setName("image.jpeg"); 
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Delete old files with same name

function myFunction() {
  var url  ="https://html.com/wp-content/uploads/flamingo.jpg";
  var response = UrlFetchApp.fetch(url);
  var blob=response.getAs('image/jpeg');
  var folderid = "1WnbHBPcYd9S4XwXpcYEMX32k********";
  const folder = DriveApp.getFolderById(folderid);
  var fileName=decodeURIComponent(url.split("/").pop());
  var files = folder.getFilesByName(fileName);
  while(files.hasNext()) {
    let file = files.next();
    Drive.Files.remove(file.getId());
  }//deletes oldfiles with same name
  var file=folder.createFile(blob);
  file.setName("image.jpeg"); 
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!