Aplikasi Drive
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Buat file Drive baru
function createFileOnDrive(name, content) {
// Create an HTML file with the name and content provided
DriveApp.createFile(name, content, MimeType.HTML);
}
Dapatkan file dari Drive
function getFileFromDrive(name) {
const files = DriveApp.getFilesByName(name);
if (files.hasNext()) {
return files.next();
} else {
console.log(`No file found with name ${name}.`);
}
}
Daftar file pada Drive pengguna
function listAllFiles() {
// Log the name of every file in the user's Drive.
const files = DriveApp.getFiles();
for (const file of files) {
console.log(file.getName());
}
}
Daftar file dalam folder
function listAllFilesInFolder(folderId) {
// Log the name of every file in the folder.
const files = DriveApp.getFolderById(folderId).getFiles();
for (const file of files) {
console.log(file.getName());
}
}
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2024-09-11 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2024-09-11 UTC."],[[["This script demonstrates how to create new HTML files in Google Drive using provided names and content with `DriveApp.createFile()`."],["It showcases retrieving specific files from Google Drive by name using `DriveApp.getFilesByName()` and handling cases where the file isn't found."],["The script provides functionality to list all files in a user's Google Drive or within a specific folder using `DriveApp.getFiles()` and `DriveApp.getFolderById()` respectively, outputting file names to the console."]]],[]]