# Rclone script in Linux

**URL:** <https://forum.rclone.org/t/rclone-script-in-linux/11955>\
**Category:** Help and Support\
**Created:** [September 21, 2019, 11:43am UTC](https://forum.rclone.org/t/rclone-script-in-linux/11955 "2019-09-21T11:43:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Misicka](https://forum.rclone.org/user_avatar/forum.rclone.org/misicka/32/3851_2.png) [@Misicka](https://forum.rclone.org/u/Misicka)\
**Post date:** [September 21, 2019, 11:43am UTC](https://forum.rclone.org/t/rclone-script-in-linux/11955/1 "2019-09-21T11:43:36Z")

</div>

Hello, I apologize in advance for being stupid 😆

In Windows I have a simple script that displays information and disappears when I press a button (the same thing I would like in Linux)

test.bat

> rclone sync -P C:\Users\Windows\Desktop\seven\seven seven:/  
> pause

 ![](https://forum.rclone.org/uploads/default/original/2X/7/77c012f9ae53ca90c46ec82f0449ce9566b74b99.png)

test.sh (this doesn't work for me)

> #!/bin/bash  
> ./rclone sync -P C:\Users\Windows\Desktop\seven\seven seven:/  
> pause

---

<div class="post-metadata">

**Author:** ![alfred](https://forum.rclone.org/user_avatar/forum.rclone.org/alfred/32/1164_2.png) [@alfred](https://forum.rclone.org/u/alfred)\
**Post date:** [September 21, 2019, 7:11pm UTC](https://forum.rclone.org/t/rclone-script-in-linux/11955/2 "2019-09-21T19:11:03Z")

</div>

What you want to do?

---

<div class="post-metadata">

**Author:** ![thestigma](https://forum.rclone.org/user_avatar/forum.rclone.org/thestigma/32/3414_2.png) [@thestigma](https://forum.rclone.org/u/thestigma)\
**Post date:** [September 21, 2019, 8:59pm UTC](https://forum.rclone.org/t/rclone-script-in-linux/11955/3 "2019-09-21T20:59:08Z")

</div>

I suck at bash but something like this should work as a replacement:

#!/bin/bash  
PUT YOUR SYNC COMMAND HERE  
read -n1 -r -p "Press any key to continue..." key

Notes:

- Linux doesn't have C: or a windows folder so obviously that part of your script is wrong. Your sync has to point to the right place to work
- I don't think there is any "pause" function equivalent on Linux, so that last line there just tells the system to wait for user input - and we specify that input to be a single key of any type. That functionally works the same. You can edit the message in the quotes to your liking as that served no technical purpose other than to let you know it's paused.

---

<div class="post-metadata">

**Author:** ![bbassotti](https://forum.rclone.org/letter_avatar_proxy/v4/letter/b/d6d6ee/32.png) [@bbassotti](https://forum.rclone.org/u/bbassotti)\
**Post date:** [September 22, 2019, 3:27pm UTC](https://forum.rclone.org/t/rclone-script-in-linux/11955/4 "2019-09-22T15:27:46Z")

</div>

#!/bin/bash  
rclone sync -P /path/to/file seven:/  
read -n 1 -s -r -p "Press any key to continue"

ps: 1) pay attention to rclone path 2) Linux use / as directory separator.

---

<div class="post-metadata">

**Author:** ![Misicka](https://forum.rclone.org/user_avatar/forum.rclone.org/misicka/32/3851_2.png) [@Misicka](https://forum.rclone.org/u/Misicka)\
**Post date:** [September 26, 2019, 12:07am UTC](https://forum.rclone.org/t/rclone-script-in-linux/11955/5 "2019-09-26T00:07:47Z")

</div>

@thestigma @bbassotti  
Thank you all, it works perfectly

small question, what is the most used/best solution for filtering/multiple folders?  
in my directory "seven" on linux I have 15 folders but only 3 of them, I want to synchronize.  
should I list them all as individual commands, or can I list them in one sync command?

something like that:

> #!/bin/bash  
> ./rclone sync -P [/home/seven/1+/home/seven2+/home/seven/3] seven:/  
> read -n 1 -s -r -p "Press any key to continue"

---

<div class="post-metadata">

**Author:** ![thestigma](https://forum.rclone.org/user_avatar/forum.rclone.org/thestigma/32/3414_2.png) [@thestigma](https://forum.rclone.org/u/thestigma)\
**Post date:** [September 26, 2019, 12:21am UTC](https://forum.rclone.org/t/rclone-script-in-linux/11955/6 "2019-09-26T00:21:30Z")

</div>

No, that synatx will not be valid. rclone needs 1 source and 1 destination

There's a few ways to handle it.  
The primitive way would be to just make 3 sync commands after each other in the script - one for each folder.

> #!/bin/bash  
> ./rclone sync /home/seven/1 seven: -P  
> ./rclone sync /home/seven/2 seven: -P  
> ./rclone sync /home/seven/3 seven: -P  
> read -n 1 -s -r -p "Press any key to continue"

This will work fine for this case since it's not very complex what you are trying to do here. (only 3 locations - and full sync of everything in them)

Second you can use rclone filtering system:

> **[Rclone Filtering](https://rclone.org/filtering/)**
>
> Rclone filtering, includes and excludes

then you would do something like

> #!/bin/bash  
> rclone sync /home seven: --include seven\*/\*\* -P  
> read -n 1 -s -r -p "Press any key to continue"

In plain english that means: start the sync operation in the /home folder, but only work on the folders that start with "seven" (seven\*) and all the files inside, including subfolders (/\*\*)

Note that I have not tested these examples - they may have minor errors in them in sytax, but you should get the gist of it.

That is sufficient for your need here, but if you want to do really complicated filtering that you can't easily put into a single command you can also create a layered filtering file if need be (see the linked docs). What is the "best" way depends on the complexity - and also to an extent what you find to be the most intuitive to understand. If you have never used regular expressions (for the filtering) that might require a little bit of study to grasp.

If you are ever in dobut and don't want to mess up (because a sync can delete files if accidentally run with wrong settings) I highly recommend you do a trial-run by adding **--dry-run** to your command(s). This will simulate the sync but do no actions, letting you see what is going to happen. Especially if you also add **--verbose** (or just -v for short) so that it tells you all the files and folders it would transfer.

> #!/bin/bash  
> rclone sync /home seven: --include seven\*/\*\* -P -v --dry-run  
> read -n 1 -s -r -p "Press any key to continue"

Give those examples a try and let me know if that solves it for you 🙂

---

<div class="post-metadata">

**Author:** ![system](https://forum.rclone.org/uploads/default/original/2X/3/39ad3235f6ffec76ccd0c81616bd55697b4c300d.png) [@system](https://forum.rclone.org/u/system)\
**Post date:** [December 25, 2019, 12:21am UTC](https://forum.rclone.org/t/rclone-script-in-linux/11955/7 "2019-12-25T00:21:33Z")

</div>

Closed on December 25, 2019, 12:21am UTC

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