Last active
April 24, 2020 02:43
-
-
Save masakuni-ito/95a796e50724f2cbf82b5b10f82840fe to your computer and use it in GitHub Desktop.
Archive updated file for GAS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function archiveUpdatedFile() { | |
var orgFileId = PropertiesService.getScriptProperties().getProperty('ORG_FILE_ID') | |
var destFolderId = PropertiesService.getScriptProperties().getProperty('DEST_FOLDER_ID') | |
var orgFile = DriveApp.getFileById(orgFileId) | |
var destFolder = DriveApp.getFolderById(destFolderId) | |
var yesterday = new Date(new Date().setDate(new Date().getDate() - 1)); | |
var destFileName = Utilities.formatDate(yesterday, 'JST', 'yyyyMMdd') + '_memo' | |
// 昨日更新されていないファイルはコピーしない | |
if (orgFile.getLastUpdated().getTime() < yesterday.getTime()) { | |
return | |
} | |
orgFile.makeCopy(destFileName, destFolder) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment