Yahoo! JAPAN Ads Script | Developer Center
日本語Google Drive
・Create a new folder・Create a new file in a folder
・List of files in a folder
Create a new folder
function createNewFolder(){
const name = 'newFolderName';
const newFolder = DriveApp.createFolder(name);
Logger.log('newFolderId -> ' + newFolder.getId());
}
Create a new file in a folder
function createNewFileInFolder(){
const folderId = '1234ABCD';
const folder = DriveApp.getFolderById(folderId);
const fileName = 'newFile';
const newFile = folder.createFile(fileName, 'Hello, world');
}
List of files in a folder
function listOfFilesInFolder(){
const folderId = '1234ABCD';
const files = DriveApp.getFolderById(folderId).getFiles();
while (files.hasNext()) {
const file = files.next();
Logger.log('fileId-> ' + file.getId() + ', fileName-> ' + file.getName());
}
}