Running several Rclone commands from a txt file

I am running Rclone version v1.54.0-beta.4766.75de30cfa on a Macbook pro to copy data from one Google Drive domain to another Google Drive domain for multiple users.
I have created two remotes which uses the service side as follows

[src]
type = drive
client_id = 10282619325030
scope = drive
service_account_file = /Users/albert/rclone-servic7d7ea65a3e.json
server_side_across_configs = true
impersonate = user1@olddomain.com

[dst]
type = drive
client_id = 10350927546194
scope = drive
service_account_file = /Users/albert/rclone2-289113-4a53.json
server_side_across_configs = true
impersonate = user1@newdomain.com

I am able to copy the data using rclone copy src: dst: --progress

My challenge is that I have to copy data between a lot of users of the two domains...like this:

user1@olddomain.com to user1@newdomain.com
user2@olddomain.com to user2@newdomain.com
user3@olddomain.com to user3@newdomain.com
user4@olddomain.com to user4@newdomain.com

From this reply - Transferring files between two users of the same domain I see that I can use environment variables to override impersonate for src and for dst separately to change the users as follows

export RCLONE_CONFIG_SRC_IMPERSONATE=user2@olddomin.com
export RCLONE_CONFIG_DST_IMPERSONATE=user2@newdomain.com

I want to know if it is possible to create a txt file with the following commands:

export RCLONE_CONFIG_SRC_IMPERSONATE=user2@olddomin.com
export RCLONE_CONFIG_DST_IMPERSONATE=user2@newdomain.com
rclone copy src: dst: --progress
export RCLONE_CONFIG_SRC_IMPERSONATE=user3@olddomin.com
export RCLONE_CONFIG_DST_IMPERSONATE=user3@newdomain.com
rclone copy src: dst: --progress
export RCLONE_CONFIG_SRC_IMPERSONATE=user4@olddomin.com
export RCLONE_CONFIG_DST_IMPERSONATE=user4@newdomain.com
rclone copy src: dst: --progress

and then run a single rclone command that calls the txt file. For example a command like rclone batch filename.txt - I know this is wrong, but it is to give an idea of what I want to achieve.

Write the text file of the commands you want and then

$ source textfile.txt

Or

$ chmod +x textfile.txt
$ ./ textfile.txt

This is using your shell to run the commands

Thanks a lot @jwink3101 this worked like a charm!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.