I am trying to write a shell script containing a rclone move command to backup my files to my drive regularly, but since I have a folder whose name has space in between, the parsing of the string goes unexpectedly.
Apparently, the problem is because I have a folder name “MacBook Backups” in myGDrive, and if you take a look at the DEBUG array, the folder name gets cut here with adding an extra slash: "myGDrive:MacBook\\" "Backups/Screenshots/".
Knowing that to add a space for a folder name in a shell script is usually by adding a slash before the space, then how I could make this script work correctly? I used to use the string value in $rcloneCommand directly as a shell command to use rclone move and it runs without a problem.
I am not so sure if this is the right place to ask this question since it is not technically related to the features of rclone, but I guess it is sort of related to its parsing mechanism? Please advise. Thanks!!
These two ways do work(I tried both of them)! Actually, at first I did use the first way you introduced to write my script, but then I was trying to make my script more versatile since in myGDrive, except “MacBook Backups”, I have a bunch of other folders whose names have space as well, so I named a variable in my script like
So if the next time I want to change my backup folder in gDrive, I can just change the value of gDriveFolder (In fact in my script Screenshots is also a folderName variable and it may contain space too). The main reason is I am planning to write an if-statement in the future to back up certain folder based on my choice.
I then tried to combine your two ways with the use of the variables, but I couldn’t find a way to get around it. Hence, based on
then it would be difficult to introduce a variable whose value contains space into the command string?
Cut and paste from stack overflow works pretty well to a certain level! Beyond that read the man page . However I prefer not to write really complicated shell scripts, I reach for a proper programming language like python or go (usually as soon as I start writing loops or functions!).