I am moving file this way:
var idOriginFolder = 'ABCDEFG12345abcdefg';
var originFolder = DriveApp.getFolderById(idOriginFolder);
var destinationFolder = DriveApp.createFolder('New Folder');
var searchString = '"'+idOriginFolder+'" in parents'
var foundFiles = DriveApp.searchFiles(searchString);
while (foundFiles.hasNext()){
var file = foundFiles.next();
destinationFolder.addFile(file);
originFolder.removeFile(file);
}
The files are moved correctly, but the modification date of every one moved file is changed to script execution date. Do you know any way to avoid this? When I move files throught of the Web Interface of Google Drive this not happen.
In my experience, the modification date of files is not changed by moving using Drive API v3. In your question, when the files were moved using DriveApp, the modification date was changed. I think that DriveApp uses Drive API v2. So I investigated this, because I was interested in this situation.
For Drive API v2drive.files.update
anddrive.files.patch
, the modification date was changed.drive.files.update
, the modification date was NOT changed.Sample script :
The sample script for using Drive API v3 is as follows.
Note :
Reference :
If this was not useful for you, I'm sorry.