Removes a file from a folder without deleting it.
class DriveApp method .removeFile()
DriveApp is the Apps Script service.
.removeFile() is the method name you will see after a dot in your code.
What it does
Why it's used
- Take a file out of a folder without deleting it from Drive.
- Tidy staging folders after processing uploads.
Common errors
- Forgetting parentheses on removeFile. Write DriveApp.removeFile(), not DriveApp.removeFile or removeFile by itself.
- Skipping dots between chained calls. Each step needs a dot, like DriveApp.getFileById(id).removeFile().
- Adding spaces where they do not belong. Write DriveApp.removeFile(), not DriveApp .removeFile(), DriveApp.removeFile (), or DriveApp . removeFile().
- Wrong capitalization. Use DriveApp and removeFile, not driveapp or removefile.
Explore
Related methods
-
.addFile()
Moves a file into a folder.
-
.createFile()
Creates a new file in Drive from a name and content.
-
.getFileById()
Loads a Drive file by its file ID.
-
.getFilesByName()
Finds files in Drive that match a given name.
-
.makeCopy()
Creates a duplicate of a file in Drive.
More Apps Script
Better Sheets tutorials
No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.
Related blog posts
Written guides about DriveApp.removeFile().
Automatic Weekly Backup of Google Sheets
How can we create backups of Google sheets every week or every day or every month?
Read post →What's Better Than Google Sheets?
Nothing is better than Google Sheets. You just need to learn more about the unlimited power of Google Sheets. Functions, Formulas, Apps Script and more.
Read post →How to reference a different Google Spreadsheet in Apps Script?
Transferring Data Between Cells in Different Spreadsheets
Read post →