Moves a file into a folder.
class DriveApp method .addFile()
DriveApp is the Apps Script service.
.addFile() is the method name you will see after a dot in your code.
What it does
Why it's used
- Move an export into the right client folder after creation.
- File generated reports without manual dragging.
Common errors
- Forgetting parentheses on addFile. Write DriveApp.addFile(), not DriveApp.addFile or addFile by itself.
- Skipping dots between chained calls. Each step needs a dot, like DriveApp.getFileById(id).addFile().
- Adding spaces where they do not belong. Write DriveApp.addFile(), not DriveApp .addFile(), DriveApp.addFile (), or DriveApp . addFile().
- Wrong capitalization. Use DriveApp and addFile, not driveapp or addfile.
Explore
Related methods
-
.removeFile()
Removes a file from a folder without deleting it.
-
.createFolder()
Creates a new folder in Drive.
-
.createFile()
Creates a new file in Drive from a name and content.
-
.makeCopy()
Creates a duplicate of a file in Drive.
-
.getFileById()
Loads a Drive file by its file ID.
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.addFile().