Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Google Drive Etiketler gelişmiş hizmetiyle Drive dosya ve klasörleriniz için etiketler oluşturup yönetin. Bu gelişmiş hizmet sayesinde, Drive Etiketler API'nin tüm özelliklerini Apps Komut Dosyası'nda kullanabilirsiniz.
Bu hizmet hakkında daha fazla bilgi için Google Drive Labels API belgelerine bakın. Apps Komut Dosyası'ndaki tüm gelişmiş hizmetler gibi Drive Etiketler API hizmeti de herkese açık API ile aynı nesneleri, yöntemleri ve parametreleri kullanır.
Sorunları bildirmek ve başka destek almak için Google Drive Labels API destek kılavuzuna bakın.
Örnek kod
Aşağıdaki örnek kodda API'nin 2. sürümü kullanılmaktadır.
Etiket listelemesi
Aşağıdaki kod örneğinde, isteği gönderen kullanıcının kullanabileceği etiketlerin listesinin nasıl alınacağı gösterilmektedir.
/** * List labels available to the user. */functionlistLabels(){letpageToken=null;letlabels=[];do{try{constresponse=DriveLabels.Labels.list({publishedOnly:true,pageToken:pageToken});pageToken=response.nextPageToken;labels=labels.concat(response.labels);}catch(err){// TODO (developer) - Handle exceptionconsole.log('Failedtolistlabelswitherror%s',err.message);}}while(pageToken!=null);console.log('Found%dlabels',labels.length);}
Etiket alma
Aşağıdaki kod örneğinde, tek bir etiketin kaynak adına (etiketin dize değeri) göre nasıl alınacağı gösterilmektedir. Etiket adını bulmak için API üzerinden etiket listesini alın veya Drive etiket yöneticisini kullanın. Etiket yöneticisi hakkında daha fazla bilgi için Drive etiketlerini yönetme başlıklı makaleyi inceleyin.
/** * Get a label by name. * @param {string} labelName The label name. */functiongetLabel(labelName){try{constlabel=DriveLabels.Labels.get(labelName,{view:'LABEL_VIEW_FULL'});consttitle=label.properties.title;constfieldsLength=label.fields.length;console.log(`Fetchedlabelwithtitle:'${title}'and${fieldsLength}fields.`);}catch(err){// TODO (developer) - Handle exceptionconsole.log('Failedtogetlabelwitherror%s',err.message);}}
Bir Drive öğesinin etiketlerini listeleme
Aşağıdaki kod örneğinde, bir Drive öğesinin nasıl alınacağı ve bu öğeye uygulanan tüm etiketlerin nasıl listeleneceği gösterilmektedir.
/** * List Labels on a Drive Item * Fetches a Drive Item and prints all applied values along with their to their * human-readable names. * * @param {string} fileId The Drive File ID */functionlistLabelsOnDriveItem(fileId){try{constappliedLabels=Drive.Files.listLabels(fileId);console.log('%dlabel(s)areappliedtothisfile',appliedLabels.labels.length);appliedLabels.labels.forEach((appliedLabel)=>{// Resource name of the label at the applied revision.constlabelName='labels/'+appliedLabel.id+'@'+appliedLabel.revisionId;console.log('FetchingLabel:%s',labelName);constlabel=DriveLabels.Labels.get(labelName,{view:'LABEL_VIEW_FULL'});console.log('LabelTitle:%s',label.properties.title);Object.keys(appliedLabel.fields).forEach((fieldId)=>{constfieldValue=appliedLabel.fields[fieldId];constfield=label.fields.find((f)=>f.id==fieldId);console.log(`FieldID:${field.id},DisplayName:${field.properties.displayName}`);switch(fieldValue.valueType){case'text':console.log('Text:%s',fieldValue.text[0]);break;case'integer':console.log('Integer:%d',fieldValue.integer[0]);break;case'dateString':console.log('Date:%s',fieldValue.dateString[0]);break;case'user':constuser=fieldValue.user.map((user)=>{return`${user.emailAddress}:${user.displayName}`;}).join(',');console.log(`User:${user}`);break;case'selection':constchoices=fieldValue.selection.map((choiceId)=>{returnfield.selectionOptions.choices.find((choice)=>choice.id===choiceId);});constselection=choices.map((choice)=>{return`${choice.id}:${choice.properties.displayName}`;}).join(',');console.log(`Selection:${selection}`);break;default:console.log('Unknown:%s',fieldValue.valueType);console.log(fieldValue.value);}});});}catch(err){// TODO (developer) - Handle exceptionconsole.log('Failedwitherror%s',err.message);}}
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 2025-06-05 UTC."],[[["Utilize the Google Drive Labels advanced service in Apps Script to create and manage labels for your Google Drive files and folders, leveraging the Drive Labels API."],["To use this advanced service, ensure you enable the Advanced Drive Service in your Apps Script project settings before implementation."],["Access comprehensive documentation and support resources for the Google Drive Labels API, which uses the same structure as the public API, in the provided references."],["Explore the provided sample code snippets to learn how to list available labels, retrieve specific labels by name, and list labels applied to Drive items using Apps Script."]]],[]]