파일에서 라벨 삭제하기
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
이 페이지에서는 단일 Google Drive 파일의 라벨을 삭제하는 방법을 설명합니다.
파일에서 파일 라벨 메타데이터를 삭제하려면 files.modifyLabels
메서드를 사용합니다. 요청 본문에는 파일의 라벨 집합을 수정하는 ModifyLabelsRequest
인스턴스가 포함됩니다. 요청에는 원자적으로 적용되는 수정사항이 여러 개 포함될 수 있습니다. 즉, 수정사항이 유효하지 않으면 전체 업데이트가 실패하고 (잠재적으로 종속된) 변경사항이 적용되지 않습니다.
ModifyLabelsRequest
에는 파일의 라벨 수정사항인 LabelModification
인스턴스가 포함되어 있습니다. 라벨 필드의 수정사항인 FieldModification
인스턴스도 포함될 수 있습니다. 파일에서 라벨을 삭제하려면 FieldModification.removeLabel
을 True
로 설정합니다.
성공하면 응답 본문에 요청에 의해 추가되거나 업데이트된 라벨이 포함됩니다. 이러한 항목은 Label
유형의 modifiedLabels
객체 내에 있습니다.
예
다음 코드 샘플은 labelId
를 사용하여 fileId
를 사용하여 라벨과 연결된 모든 필드를 삭제하는 방법을 보여줍니다. 예를 들어 라벨에 텍스트와 사용자 필드가 모두 포함된 경우 라벨을 삭제하면 라벨과 연결된 텍스트와 사용자 필드가 모두 삭제됩니다. 반면 텍스트 필드를 설정 해제하면 라벨에서 텍스트 필드가 삭제되지만 사용자 필드는 그대로 유지됩니다. 자세한 내용은 파일의 라벨 필드 선택 해제를 참고하세요.
자바
ModifyLabelsRequest modifyLabelsRequest =
new ModifyLabelsRequest()
.setLabelModifications(
ImmutableList.of(
new LabelModification()
.setLabelId("LABEL_ID")
.setRemoveLabel(true)));
ModifyLabelsResponse modifyLabelsResponse = driveService.files().modifyLabels("FILE_ID", modifyLabels
Request).execute();
Python
label_modification = {'labelId':'LABEL_ID', 'removeLabel': True]}
modified_labels = drive_service.files().modifyLabels(fileId="FILE_ID", body = {'labelModifications
' : [label_modification]}).execute();
Node.js
/**
* Remove a label on a Drive file
* @return{obj} updated label data
**/
async function removeLabel() {
// Get credentials and build service
// TODO (developer) - Use appropriate auth mechanism for your app
const {GoogleAuth} = require('google-auth-library');
const {google} = require('googleapis');
const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive'});
const service = google.drive({version: 'v3', auth});
const labelModification = {
'labelId': 'LABEL_ID',
'removeLabel': True,
};
const labelModificationRequest = {
'labelModifications': [labelModification],
};
try {
const updateResponse = await service.files.modifyLabels({
fileId: 'FILE_ID',
resource: labelModificationRequest,
});
return updateResponse;
}
catch (err) {
// TODO (developer) - Handle error
throw err;
}
다음을 바꿉니다.
- LABEL_ID: 수정할 라벨의
labelId
입니다. 파일의 라벨을 찾으려면 files.listLabels
메서드를 사용합니다.
- FILE_ID: 라벨이 수정된 파일의
fileId
입니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-09-01(UTC)
[null,null,["최종 업데이트: 2025-09-01(UTC)"],[],[],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\"\u003equot;LAB\u003c/var\u003eEL_ID\")\n .setRemoveLabel(true)));\n\n ModifyLabelsResponse modifyLabelsResponse = driveService.files().modi\u003cvar translate=\"no\"\u003efyLabel\u003c/var\u003es(\"FILE_ID\", modifyLabelsRequest).execute();\n\nPython \n\n label_modification = {'labelI\u003cvar translate=\"no\"\u003ed'\u003c/var\u003e:'LABEL_ID', 'removeLabel': True]}\n\n modified_labels = drive_service.files\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-p\"\u003e()\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e.\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003emodi\u003c/span\u003e\u003c/var\u003efyLabels(fileId=\"FILE_ID\", 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 labelM\u003cvar translate=\"no\"\u003eodificat\u003c/var\u003eion = {\n 'labelId': 'LABEL_ID',\n 'removeLabel': True,\n };\n const labelModificationRequest = {\n 'labelModifications': [labelModification],\n };\n try {\n const upd\u003cvar translate=\"no\"\u003eateResp\u003c/var\u003eonse = await service.files.modifyLabels({\n fileId: 'FILE_ID',\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."]]