How to Add File/Folder to Multiple Folders of Google Drive on Mobile

Share on facebook
Share on twitter
Share on pinterest

Google Drive has a feature for adding multiple files or folders to different directories without having to copy them individually. If you edit a file in a folder, all the instances of the file are updated automatically.

To do this, please follow these steps,

  1. Login to your Google drive in a browser,
  2. Select your intended file or folder, 
  3. Press Shift+Z, 
  4. Select your destination folder

However, this feature is not available on the Google Drive app for mobile devices because you can’t select a file or folder and simultaneously press Shift and Z buttons on your phone.

In this blog, we discuss a workaround for Shift+Z functionality for the Google Drive app on mobile devices such as Android phones or iPhones.

Google App Script Solution Instead of Shift+Z

To perform Shift+Z on Google Drive Mobile App, please run the app script explained in this blog. 

Find the ID of Google Drive File

First, find the ID of the source file or folder. The URL of the file and folder contains their unique ID.  To determine a file ID, by right-clicking the slight file, select SHARE, and click ADVANCED, everything after https://drive.google.com/drive/folders/ is your file ID.

Determination of file ID on Google Drive
Determination of file ID on Google Drive
Determination of file ID on Google Drive

Find the ID of Google Drive Folder

To achieve the folder ID, open it and use the URL in the address field of the browser, as shown in the image.

Google Drive Folder ID
Determination of folder ID in Google Drive

Also, to have the file/folder ID on the mobile device, select the vertical ellipsis beside the file/folder and choose Copy Link, like the image below, and extract the ID.

Google drive Folder - Copy Link
Determination of folder ID in Google Drive

Copy Code to Google App Script

Next, create a new project in https://script.google.com/. And copy-paste the following code in your new project file, and save it.

// This function add a file or folder to another folder.
function ShiftZ() {
                                                                                                 
  // Original File or Folder
  
  // If you want to add a file to a folder, enter the file ID inside the quotations below.
  // If you're not adding any file, leave inside the quotation blank
  var orgFileID = ""; // <<-- **Attention!** Insert the ID, if any, before running the function
  
  // If you want to add a folder to a folder, enter the folder ID inside the quotations below.
  // If you're not adding any folder, leave inside the quotation blank
  var orgFolderID = ""; // <<-- **Attention!** Insert the ID, if any, before running the function
  
  // Destination Folder
  
  // Enter the ID of the destination folder
  var desFolderID = ""; // <<-- **Attention!** Insert the ID, before running the function
 
  if (orgFileID.length > 0 ) {
      var orgFile = DriveApp.getFileById(orgFileID);
      DriveApp.getFolderById(desFolderID).addFile(orgFile);  // Add the report folder to Ahmad's Dabiri Folder
  }
  
  if (orgFolderID.length > 0 ) {
      var orgFolder = DriveApp.getFolderById(orgFolderID);
      DriveApp.getFolderById(desFolderID).addFolder(orgFolder); // Add the account folder to admin folder
  }
}

Next, set the variables as follows:

  • If you want to add a file to multiple folders, set the orgFileID variable equal to the file ID.
  • If you want to add a folder to another folder, set orgFolderID variable equal to the original folder ID. 
  • And set the desFolderID variable equal to the ID of the destination folder.

Run ShiftZ Function

To execute the ShiftZ function, select the function from the dropdown and click the Start icon, as shown in the image below.

Run ShiftZ Function on Google Drive Script
Run ShiftZ function on Google Drive Script.

Google Drive might ask you for permission to execute the app script when you run the script for the first time. After the execution, check the destination folder to verify if your file/folder is added.

Starred Projects


You can add a star to this project file to list it in your Starred Projects for quick access for later uses. In your G Suites Developers Hub, select your project, click the vertical three dots in front of it, and select “Add star”, as explained in the image below.

Starred projects for quick access - Google Drive
Starred projects for quick access – Google Drive

The project is then added to your Starred Projects.

Starred projects for quick access - Google Drive
Starred projects for quick access – Google Drive

Subscribe to our Newsletter

Share this post with your friends

Share on facebook
Share on google
Share on twitter
Share on linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *