Trash or delete files and folders  |  Google Drive  |  Google for Developers (2024)

You can remove Google Drive files and folders from both your MyDrive and shared drives. You have two options to do this: trashor delete.

You can move files and folders into the trash and then restore them (within 30days of trashing them). Deleting files and folders removes them permanently fromDrive. If you trash, restore, or permanently delete multiplefiles or folders at once, it might take time for you to notice the changes.

This guide explains how you can dispose of files in Drive.

Trash

To remove Drive files, you can move them to the trash. Files inthe trash are automatically deleted after 30 days. You can restore files fromyour trash before the 30-day period.

Only the file owner can trash a file, and other users can't view files in theowner's trash. If you attempt to trash a file you don't own, you receive aninsufficientFilePermissionserror. For more information, see Permissions.

To verify you're the file owner, call thefiles.get method with the fileIdand the fields parameter set to the boolean ownedByMe field. The ownedByMefield isn't populated for files in shared drives because they're owned by theshared drive, not individual users. For further information about returningfields using the fields parameter, see Return specific fields for afile.

If you're not the file owner but still want a copy of the trashed file, do oneof the following:

  • Make a copy of the file.
  • Contact the owner to have them restore it from the trash.

Move a file to the trash

To move a file to the trash, use thefiles.update method and set thetrashed field to True. To trash a shared drive file, you must also set thesupportsAllDrives query parameter to True. For more information, seeImplement shared drive support.

If successful, the responsebody contains aninstance of the files resource.

The following code sample shows how to use the fileId to mark the file astrashed:

Python

body_value = {'trashed': True}response = drive_service.files().update(fileId="FILE_ID", body=body_value).execute()

Node.js

const body_value = { 'trashed': True};const response = await drive_service.files.update({ fileId: 'FILE_ID', requestBody: body_value, }); return response;

Replace FILE_ID with the fileId of the file that you want totrash.

Determine a trashed file's properties

When a file is trashed, you can retrieve additionalfiles properties. You can use thefiles.get method and include thefollowing fields in the fields parameter. For more information, see Returnspecific fields for a file.

The following fields are populated for all files:

  • trashed: Whether the file was trashed, either explicitly or from a trashedparent folder. Note that while using trashed with the files.updatemethod sets the file's status, the files.get method retrieves the file'sstatus.
  • explicitlyTrashed: Whether the file was explicitly trashed, as opposed torecursively trashed, from a parent folder.

The following fields are only populated for files located within a shared drive:

  • trashedTime: The time that the item was trashed in RFC3339date-time format. If you're using the previous Drive API v2version, this field is called trashedDate.
  • trashingUser: If the file was explicitly trashed, the user who trashed it.

Recover a file from the trash

To recover a file from the trash, use thefiles.update method and set thetrashed field to False. To untrash a shared drive file, you also must setthe supportsAllDrives query parameter to True. For more information, seeImplement shared drive support.

If successful, the responsebody contains aninstance of the files resource.

The following code sample shows how to use the fileId to mark the file asuntrashed:

Python

body_value = {'trashed': False}response = drive_service.files().update(fileId="FILE_ID", body=body_value).execute()

Node.js

const body_value = { 'trashed': False};const response = await drive_service.files.update({ fileId: 'FILE_ID', requestBody: body_value, }); return response;

Replace FILE_ID with the fileId of the file that you want tountrash.

Empty trash

You can permanently delete all Drive files the user has moved tothe trash using thefiles.emptyTrash method. Toempty the trash of a shared drive, you must also set the driveId queryparameter to the shared drive ID.

If successful, the responsebody contains an emptyinstance.

The following code sample shows how to use the fileId to delete all files inthe trash:

Python

response = drive_service.files().emptyTrash().execute()

Node.js

 const response = await drive_service.files.emptyTrash({ }); return response;

Delete

You can permanently delete a Drive file without moving it to thetrash. After you delete a file, anyone you've shared the file with loses accessto it. If you want others to retain access to the file, you can transferownership tosomeone else before deletion.

To delete a shared drive file, the user must have role=organizer on the parentfolder. If you're deleting a folder, all descendants owned by the user are alsodeleted. For more information, see Permissions.

To permanently delete a user-owned file without moving it to the trash, use thefiles.delete method. To delete ashared drive file, you must also set the supportsAllDrives query parameter toTrue. For more information, see Implement shared drivesupport.

If successful, the responsebody contains anempty instance.

The following code sample shows how to use the fileId to delete the file:

Python

response = drive_service.files().delete(fileId="FILE_ID").execute()

Node.js

 const response = await drive_service.files.delete({ fileId: 'FILE_ID' }); return response;

Replace FILE_ID with the fileId of the file that you want todelete.

Permissions

The following table shows the role permissions required to perform eachoperation. For a complete list of roles and the operations permitted by each,refer to Roles and permissions.

Permitted operationownerorganizerfileOrganizerwritercommenterreader
Move files and folders into the trash
Recover files and folders from the trash
Empty the trash
Permanently delete a file or folder
Delete files and folders in a shared drive [*]

Capabilities

A files resource contains a collectionof boolean capabilities fields used to indicate whether an action can beperformed on a file.

To check the capabilities, call thefiles.get method with the fileIdand the fields parameter set to the capabilities field. For furtherinformation about returning fields using the fields parameter, see Returnspecific fields for a file.

The following fields are populated for all files:

  • capabilities.canTrash: Whether the current user can move this file totrash.
  • capabilities.canUntrash: Whether the current user can restore this filefrom trash.
  • capabilities.canDelete: Whether the current user can delete this file.
  • capabilities.canRemoveChildren: Whether the current user can removechildren from this folder. This is false when the item isn't a folder.

The following fields are only populated for files located within a shared drive:

  • capabilities.canTrashChildren: Whether the current user can trash childrenof this folder. This is false when the item isn't a folder.
  • capabilities.canDeleteChildren: Whether the current user can deletechildren of this folder. This is false when the item isn't a folder.

File and folder limits

Drive files and folders, along with shared drive folders, havesome storage limits.

Generally, after the item limit is reached, the only way to create more space isto permanently delete items or use adifferent account. Moving files to the trash isn't enough to free up space.

For more information on file and folder limits, see the following:

  • File and folder limits in files
  • File and folder limits in shared drives
  • Delete files in Google Drive
  • Shared drive versus My Drive API differences
  • Roles and permissions
Trash or delete files and folders  |  Google Drive  |  Google for Developers (2024)

FAQs

Trash or delete files and folders  |  Google Drive  |  Google for Developers? ›

To remove Drive files

files
Files (formerly known as Files Go) is a file management app developed by Google for file browsing, media consumption, storage clean-up and offline file transfer.
https://en.wikipedia.org › wiki › Files_(Google)
, you can move them to the trash. Files in the trash are automatically deleted after 30 days. You can restore files from your trash before the 30-day period. Only the file owner can trash a file, and other users can't view files in the owner's trash.

How do I delete files and folders in Google Drive? ›

On your computer, go to drive.google.com. On the left, click Trash. Select a file. At the top, click Delete forever.

How do I delete unnecessary files from Google Drive? ›

If you're not the owner, others can access the file even if you empty your trash.
  1. On your Android phone or tablet, open the Google Drive app.
  2. At the bottom right, tap Files .
  3. Next to the file you want to delete, tap More. Remove.

Does Google Drive have a Trash folder? ›

Permanently delete all files in your trash

On your computer, go to drive.google.com. On the left, click Trash. Make sure there are no files you want to keep. At the top right, click Empty trash.

Why can't I delete folder in Google Drive? ›

To delete a shared drive file, the user must have role=organizer on the parent folder. If you're deleting a folder, all descendants owned by the user are also deleted. For more information, see Permissions.

How do I clear Google Drive data? ›

Clean up storage through Google One
  1. On your Android device, open the Google One app .
  2. At the bottom, tap Storage. Free up account storage.
  3. Select the category you want to manage.
  4. Select the files you want to remove. To sort files, at the top, tap Filter . ...
  5. After you select your files, at the top, tap Delete .

Does Google Drive trash take up space? ›

Items in your Trash take up space in Google Drive, but aren't synced to your computer. Learn how to empty your trash. Shared items take up space on your computer, but not Google Drive. Items that are in multiple folders sync to all folders on your computer and take up more space.

Can I recover files after I empty trash on Google Drive? ›

To restore Drive files for your own account, go to Find or recover a file. As an administrator, you can recover deleted items from Google Drive within 25 days after a user empties their trash. After that period, Google purges the data from its systems.

Does Google Drive keep deleted files? ›

Google Drive keeps deleted files in a Trash folder for 30 days. Additionally, it keeps permanently deleted files for 25 days in corporate Google Workspace subscription plans.

How do I declutter Google Drive? ›

Tips to organize your files:
  1. Use folders inside folders: Start with a simple structure and adjust as you need. ...
  2. Use clear names: Use easy-to-understand names for your files and folders. ...
  3. Color code your folders: Use colors to label folders. ...
  4. Star your favorites: Put a star on files you need to find quickly.

How do I free up space in Google Drive? ›

2 Free up space in Drive

Find and remove large files: Go to drive.google.com/drive/quota, where your files are listed in order from biggest to smallest. Right-click a file that you want to delete and then click Move to Trash.

How do I delete all empty folders in Google Drive? ›

Bulk Delete Your Empty Folders in Google Drive

After viewing your empty folders, you can easily delete them all with a simple click (or delete a subset using filters). Go to the empty folders page and click the delete button.

How do I manage files and folders in Google Drive? ›

Tips to organize your files:
  1. Use folders inside folders: Start with a simple structure and adjust as you need. ...
  2. Use clear names: Use easy-to-understand names for your files and folders. ...
  3. Color code your folders: Use colors to label folders. ...
  4. Star your favorites: Put a star on files you need to find quickly.

How do I delete recent files in Google Drive? ›

To clear your entire recent file history, follow these steps:
  1. Open Google Files.
  2. Tap on the Menu button (three horizontal lines) in the top left corner of the screen.
  3. Tap on Settings.
  4. Tap on Clear recent file history.
  5. Tap on Clear.
Oct 8, 2023

How do I delete multiple files at once? ›

Tip: You can also select more than one file to be deleted at the same time. Press and hold the CTRL key as you select multiple files to delete. To select a long list of files click the first file in the list, press and hold SHIFT, then click the last file in the list.

Top Articles
Top themes in insurance for 2024
Gross Profit Margin: Formula and What It Tells You
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Selly Medaline
Latest Posts
Article information

Author: Pres. Lawanda Wiegand

Last Updated:

Views: 5516

Rating: 4 / 5 (71 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Pres. Lawanda Wiegand

Birthday: 1993-01-10

Address: Suite 391 6963 Ullrich Shore, Bellefort, WI 01350-7893

Phone: +6806610432415

Job: Dynamic Manufacturing Assistant

Hobby: amateur radio, Taekwondo, Wood carving, Parkour, Skateboarding, Running, Rafting

Introduction: My name is Pres. Lawanda Wiegand, I am a inquisitive, helpful, glamorous, cheerful, open, clever, innocent person who loves writing and wants to share my knowledge and understanding with you.