LoginSignup
3
1

More than 5 years have passed since last update.

【GAS】マイドライブからファイルを移動する

Posted at

GASでフォームなどのファイル作成したあとにフォルダ移動したくなり、
id指定で動作する汎用的な関数を作りました。

ポイントとしては最後にマイドライブから消す必要がある。(消さない場合もファイルは同じものを参照する)


function moveFromRootToFolder(file_id, folder_id) {
  var file = DriveApp.getFileById(file_id);
  DriveApp.getFolderById(folder_id).addFile(file);
  DriveApp.getRootFolder().removeFile(file);
}
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1