Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9704

Change File Name Automation in Google App Script

$
0
0

I am working on a script in App Script that will change the file name of all the files in a certain folder based on their creation date using this format yyyy_MM_dd_filename. I was able to create the script and it is working when I run it however everytime I run it again it appends another date on the file name which makes it duplicated.

What I wanted to happen is that when I run the script with a new file it will not change the file name of those who have already the date format that I created but instead just changed those that was just saved and newly uploaded in Google Drive.

This is my code:

function changeName() {      var folder_access = DriveApp.getFolderById("1qSQ-K2R97PIfDHztmU0iwM0y_GxPk2zG");      var folder_files = folder_access.getFiles();      var file_name = folder_files.next();      var filename_format = Utilities.formatDate(new Date(file_name.getDateCreated()), "GMT", "yyyy_MM_dd");      file_name.setName(filename_format+"_"+file_name);}

Viewing all articles
Browse latest Browse all 9704

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>