با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
با سرویس پیشرفته Google Drive Labels، برچسبها را برای فایلها و پوشههای Drive خود ایجاد و مدیریت کنید. با استفاده از این سرویس پیشرفته، می توانید از تمام ویژگی های Drive Labels API در Apps Script استفاده کنید.
برای اطلاعات بیشتر درباره این سرویس، به مستندات Google Drive Labels API مراجعه کنید. مانند همه سرویسهای پیشرفته در Apps Script، سرویس Drive Labels API از اشیاء، روشها و پارامترهای مشابه API عمومی استفاده میکند.
برای گزارش مشکلات و یافتن پشتیبانی دیگر، راهنمای پشتیبانی Google Drive Labels API را ببینید.
/** * 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);}
یک برچسب دریافت کنید
نمونه کد زیر نشان می دهد که چگونه می توان یک برچسب را با نام منبع آن (که مقدار رشته برچسب است) بدست آورد. برای پیدا کردن نام برچسب، فهرست برچسبها را از طریق API دریافت کنید یا از مدیریت برچسبهای Drive استفاده کنید. برای اطلاعات بیشتر درباره مدیریت برچسبها، به مدیریت برچسبهای Drive بروید.
/** * 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);}}
برچسبها را برای یک مورد Drive فهرست کنید
نمونه کد زیر نحوه دریافت یک مورد Drive را نشان میدهد و همه برچسبهای اعمال شده روی آن مورد را فهرست میکند.
/** * 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);}}
تاریخ آخرین بهروزرسانی 2025-06-05 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-06-05 بهوقت ساعت هماهنگ جهانی."],[[["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."]]],[]]