Tuesday, 19 November 2024

Copy or move file into folder Tool

The following Google Apps Script tool allows you to quickly copy or move existing files into existing folders within Google/Shared drive. This is quite a niche tool so it is anticipated you would already have a Google Sheet of file IDs/URLs, though there is the option to select an existing Drive folder of files and automatically bring them into this tool.

You can continue to append further rows to the Google Sheet as existing ones will be skipped once the ‘Status’ column has automatically been marked as ‘Completed’. Alternatively you can clear the Sheet each time for a fresh start.

Quickly copy or move existing files into folders via a Google Sheet
Quickly copy or move existing files into folders via a Google Sheet


Instructions

  1. Open the relevant Google Sheet file and then go to “File” and select “Make a copy”, then choose a suitable location. This will make a copy of the tool in your own Google Drive.

  2. Start to complete the relevant columns in the Google Sheet. You do not need to add all files at this point but you should ensure you complete the required information for any rows that you do start.

    • File ID or URL - required, unless using the 'Select a folder of files' option from the ‘Admin’ menu. This is the file you want to copy/move. Do not convert to a Smart Chip.

    • File Name - unless using the ‘Select a folder of files’ option from the ‘Admin’ menu, please use the ‘Get file names’ option to scan through your existing IDs/URLs and automatically populate their name.

    • Folder ID or URL - required, unless using the 'Select destination folder' option from the ‘Admin’ menu. This is the folder you want to copy/move. Do not convert to a Smart Chip.

    • Folder Name - unless using the ‘Select destination folder’ option from the ‘Admin’ menu, please use the ‘Get folder names’ option to scan through your existing IDs/URLs and automatically populate their name.

    • Operation - required - skips row if left blank. Choose from either ‘Copy’ or ‘Move’.

    • Status - will be updated automatically.

    • Notes - optional - just a column for you if you wish to add some information.

    • If you wish to append further Columns from ‘H’ onwards then you may.

  3. Select a folder of files - use this option if you do not have an existing list of file IDs/URLs from another Google Sheet to paste in. This will allow you to collate a Google Drive folder of files (they must be all at one level i.e. the tool will not iterate through subfolders).

    • Click the ‘Admin’ option from the menu bar at the top and then ‘Select a folder of files’. Read the information in the dialogue box carefully and click ‘Yes’ to proceed.

    • Search for your Google Drive folder by entering its name into the search bar at the top left. Click once to highlight it then click the ‘Select’ button. Be patient at this point as there may be a delay whilst all of your files are collated into the Google Sheet and the pop-up remains on-screen.

    • You can now complete the information in the Google Sheet as per Step 2 above, ignoring columns A and B.

  4. Select destination folder option - use this option if you do not have an existing list of folder IDs/URLs from another Google Sheet to paste in. This will allow you to collate a Google Drive folder of folders (they must be all at one level i.e. the tool will not iterate through subfolders).

    • Click the ‘Admin’ option from the menu bar at the top and then ‘Select destination folder’. Read the information in the dialogue box carefully and click ‘Yes’ to proceed.

    • Search for your Google Drive folder by entering its name into the search bar at the top left. Click once to highlight it then click the ‘Select’ button. Be patient at this point as there may be a delay whilst your folder is collated into the Google Sheet and the pop-up remains on-screen.

    • You can now complete the information in the Google Sheet as per Step 2 above, ignoring columns C and D.

  5. Run the tool.

    • Once you have completed the Google Sheet click the ‘Admin’ option from the menu bar at the top and then ‘Run the tool’.

    • This will now automatically loop through each row and append permissions. The ‘Status’ column will be updated for you. This column also serves as a way of skipping rows should you wish to append further folders in future - so unless it is blank the said row will be ignored. Whilst this is running please leave the Google Sheet open, but you can continue to work on other tasks should you wish. The process will not slow down your PC or internet connection.

    • A pop-up message will appear in the Google Sheet at the end to inform you when it has completed.

Caveats

  • Fixed columns/rows
    • You must not add/delete/move any of the blue columns (A to G) otherwise the tool will break. Nor should you try to insert a new row above the current row 83. You absolutely can add further columns/data from H onwards if you wish.

  • Smart Chips
    • Do not accept the automated Google prompt to convert your File/Folder URLs (Column A and C) into a Smart Chip (this is usually by clicking on the prompt or by pressing the Tab key). Whilst this is useful and looks nicer in other circumstances, it will break the automation here unfortunately as Google have not made Apps Script compatible with them.



Download

Copy or move file into folder Tool download (please use 'File' > 'Make a copy' for your own version).


No comments:

Post a Comment