تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
توضّح هذه الصفحة كيفية إزالة تصنيف من ملف واحد في Google Drive.
لإزالة البيانات الوصفية لتصنيف الملف من ملف، استخدِم طريقة
files.modifyLabels. يحتوي نص الطلب على مثال ModifyLabelsRequest لتعديل مجموعة التصنيفات في ملف. قد يحتوي الطلب على عدة تعديلات يتم تطبيقها بشكل متزامن. وهذا يعني أنّه إذا كانت أي تعديلات غير صالحة، سيتعذّر إجراء التعديل بالكامل ولن يتم تطبيق أي من التغييرات (التي قد تكون مرتبطة).
يحتوي ModifyLabelsRequest على مثيل من
LabelModification
وهو تعديل على تصنيف في ملف. قد يحتوي أيضًا على مثيل
FieldModification
وهو تعديل على حقل تصنيف. لإزالة التصنيف من الملف،
اضبط قيمة FieldModification.removeLabel على True.
في حال نجاح الطلب، يحتوي نص الاستجابة على التصنيفات التي تمت إضافتها أو تعديلها. تتوفّر هذه السمة ضمن الكائن modifiedLabels من النوع Label.
مثال
يوضّح نموذج الرمز البرمجي التالي كيفية استخدام labelId لإزالة جميع الحقول المرتبطة بالتسمية باستخدام fileId. على سبيل المثال، إذا كان التصنيف يحتوي على حقلَي نص ومستخدم، سيؤدي حذف التصنيف إلى حذف كلٍّ من حقلَي النص والمستخدم المرتبطَين بالتصنيف. في المقابل، يؤدي إلغاء ضبط حقل النص إلى إزالته من التصنيف مع ترك حقل المستخدم بدون تغيير. لمزيد من المعلومات، يُرجى الاطّلاع على إزالة قيمة حقل تصنيف من ملف.
/*** Remove a label on a Drive file* @return{obj} updated label data**/asyncfunctionremoveLabel(){// Get credentials and build service// TODO (developer) - Use appropriate auth mechanism for your appconst{GoogleAuth}=require('google-auth-library');const{google}=require('googleapis');constauth=newGoogleAuth({scopes:'https://www.googleapis.com/auth/drive'});constservice=google.drive({version:'v3',auth});constlabelModification={'labelId':'LABEL_ID','removeLabel':True,};constlabelModificationRequest={'labelModifications':[labelModification],};try{constupdateResponse=awaitservice.files.modifyLabels({fileId:'FILE_ID',resource:labelModificationRequest,});returnupdateResponse;}catch(err){// TODO (developer) - Handle errorthrowerr;}
غيِّر القيم في السلسلة على الشكل التالي:
LABEL_ID: labelId التصنيف المطلوب تعديله للعثور على التصنيفات في ملف، استخدِم الطريقة files.listLabels.
FILE_ID: fileId الملف الذي تم تعديل التصنيفات الخاصة به.
تاريخ التعديل الأخير: 2025-09-02 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-09-02 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["This page describes how to remove a label on a single Google Drive file.\n\nTo remove the file label metadata from a file, use the\n[`files.modifyLabels`](/workspace/drive/api/v2/reference/files/modifyLabels) method. The\n[request body](/workspace/drive/api/reference/rest/v2/files/modifyLabels#request-body)\ncontains an instance of\n[`ModifyLabelsRequest`](/workspace/drive/api/reference/rest/v2/files/modifyLabels#modifylabelsrequest)\nto modify the set of labels on a file. The request might contain several\nmodifications that are applied atomically. That is, if any modifications aren't\nvalid, then the entire update is unsuccessful and none of the (potentially\ndependent) changes are applied.\n\nThe `ModifyLabelsRequest` contains an instance of\n[`LabelModification`](/workspace/drive/api/reference/rest/v2/files/modifyLabels#labelmodification)\nwhich is a modification to a label on a file. It might also contain an instance\nof\n[`FieldModification`](/workspace/drive/api/reference/rest/v2/files/modifyLabels#fieldmodification)\nwhich is a modification to a label's field. To remove the label from the file,\nset `FieldModification.removeLabel` to `True`.\n\nIf successful, the [response\nbody](/workspace/drive/api/reference/rest/v2/files/modifyLabels#response-body) contains\nthe labels added or updated by the request. These exist within a\n`modifiedLabels` object of type [`Label`](/workspace/drive/api/reference/rest/v2/Label).\n\nExample\n\nThe following code sample shows how to use the `labelId` to remove all fields\nassociated with the label using the `fileId`. For example, if a label contains\nboth text and user fields, removing a label deletes *both* the text and user\nfields associated with the label. Whereas, unsetting the text field removes it\nfrom the label but leaves the user field untouched. For more information, see\n[Unset a label field on a file](/workspace/drive/api/guides/unset-label). \n\nJava \n\n ModifyLabelsRequest modifyLabelsRequest =\n new ModifyLabelsRequest()\n .setLabelModifications(\n ImmutableList.of(\n new LabelModification()\n .setLabelId(\"\u003cvar translate=\"no\"\u003eLABEL_ID\u003c/var\u003e\")\n .setRemoveLabel(true)));\n\n ModifyLabelsResponse modifyLabelsResponse = driveService.files().modifyLabels(\"\u003cvar translate=\"no\"\u003eFILE_ID\u003c/var\u003e\", modifyLabelsRequest).execute();\n\nPython \n\n label_modification = {'labelId':'\u003cvar translate=\"no\"\u003eLABEL_ID\u003c/var\u003e', 'removeLabel': True]}\n\n modified_labels = drive_service.files().modifyLabels(fileId=\"\u003cvar translate=\"no\"\u003eFILE_ID\u003c/var\u003e\", body = {'labelModifications' : [label_modification]}).execute();\n\nNode.js \n\n /**\n * Remove a label on a Drive file\n * @return{obj} updated label data\n **/\n async function removeLabel() {\n // Get credentials and build service\n // TODO (developer) - Use appropriate auth mechanism for your app\n\n const {GoogleAuth} = require('google-auth-library');\n const {google} = require('googleapis');\n\n const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive'});\n const service = google.drive({version: 'v3', auth});\n const labelModification = {\n 'labelId': '\u003cvar translate=\"no\"\u003eLABEL_ID\u003c/var\u003e',\n 'removeLabel': True,\n };\n const labelModificationRequest = {\n 'labelModifications': [labelModification],\n };\n try {\n const updateResponse = await service.files.modifyLabels({\n fileId: '\u003cvar translate=\"no\"\u003eFILE_ID\u003c/var\u003e',\n resource: labelModificationRequest,\n });\n return updateResponse;\n } catch (err) {\n // TODO (developer) - Handle error\n throw err;\n }\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eLABEL_ID\u003c/var\u003e: The `labelId` of the label to modify. To locate the labels on a file, use the [`files.listLabels`](/workspace/drive/api/v2/reference/files/listLabels) method.\n- \u003cvar translate=\"no\"\u003eFILE_ID\u003c/var\u003e: The `fileId` of the file for which the labels are modified."]]