Add Files/Folders to Multiple Drive Folders on Mobile
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,
- Login to your Google drive in a browser,
- Select your intended file or folder,
- Press Shift+Z,
- 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.
// 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
}
}
,
// 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
}
}
px” aria-hidden=”true” class=”wp-block-spacer”>
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.
<!– wp:embed {“url”:”https://youtu.be/tU
,
// 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
}
}
lQqfbJ-M”,”type”:”video”,”providerNameSlug”:”youtube”,”responsive”:true,”align”:”center”,”className”:”caption-align-center wp-embed-aspect-16-9 wp-has-aspect-ratio”} –>
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.
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.
<!– wp:image {“align”:”center”,”id”:867,”width”:512,”height”:47
,
// 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
}
}
,”sizeSlug”:”large”,”className”:”caption-align-center”,”captionAlignment”:”center”} –>
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.
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.
// 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
}
}
,
// 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
}
}
px” aria-hidden=”true” class=”wp-block-spacer”>
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.
The project is then added to your Starred Projects.
<!– wp:image {“align”:”center”,”id”:87
,
// 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
}
}
,”sizeSlug”:”large”,”className”:”caption-align-center”,”captionAlignment”:”center”} –>
Boost your productivity by getting a free consultation from Excel experts, and discover tailored solutions to optimize your data management and analysis.
Our experts will be glad to help you, If this article didn't answer your questions.
We believe this content can enhance our services. Yet, it's awaiting comprehensive review. Your suggestions for improvement are invaluable. Kindly report any issue or suggestion using the "Report an issue" button below. We value your input.
Thank you so much for this script. Is there a way to use a list of file IDs to make a copy of the file?