Apps Script公式リファレンス: Apps Script Reference |障害・課題追跡: IssueTracker |Google Workspace: Status Dashboard - Summary

2021年2月21日日曜日

GoogleドライブのファイルやフォルダをmoveTo(destination)で移動したい


moveTo(destination)というメソッドができていたので試してみました。

以下のメソッドは廃止されたようです。
 addFile(child) 
 addFolder(child) 
 removeFile(child)
 removeFolder(child) 

Deprecated methods
https://developers.google.com/apps-script/reference/drive/folder#deprecated-methods_1


ファイルを移動したい

コード.gs
function moveFile() {
  const fileId = "移動したいファイルID";
  const destinationFolderId = "移動先のフォルダID";
  
  const file = DriveApp.getFileById(fileId);
  const destinationFolder = DriveApp.getFolderById(destinationFolderId);
  
  file.moveTo(destinationFolder);
}


フォルダを移動したい

コード2.gs
function moveFolder() {
  const folderId = "移動したいフォルダのID";
  const destinationFolderId = "移動先のフォルダID";
  
  const folder = DriveApp.getFileById(folderId);
  const destinationFolder = DriveApp.getFolderById(destinationFolderId);
  
  folder.moveTo(destinationFolder);
}


参考

moveTo(destination) 

Deprecated methods

Release Notes
July 27, 2020

Latest post

Google Apps Scriptの障害時はIssueTrackerを見てみる - Incidents for Apps Script are reported on Issue Tracker

IssueTracker > Apps Script issues https://issuetracker.google.com/savedsearches/566234 Google Apps Scriptの障害時は IssueTracker に課題が上がっていることが...