Why won’t rsync recognize directories with spaces?

0
25
Asked By CuriousCoder42 On

I'm having a tough time with rsync not properly handling spaces in directory names. I'm trying to sync files between a Windows 11 NTFS partition and OpenSUSE LEAP 15.6. The partition sometimes doesn't mount automatically at /mnt/CROSSPLATFORM, so I set up a variable to check whether the mount was successful and adjust accordingly. However, when I run rsync, it fails to change directories due to the spaces in the paths. I've tried every escaping method I can think of – no escapes, backslashes, quotes – but nothing works. I keep getting errors related to changing directories and it ends up creating directories with escape characters in the names, which isn't what I want. Here's my script for reference:

```
#!/bin/bash
if mountpoint -q /run/media/fool/CROSSPLATFORM
then
DIR="/run/media/fool/CROSSPLATFORM/Documents/Games/Baldurs Gate 3/"
else
DIR="/mnt/CROSSPLATFORM/Documents/Games/Baldurs Gate 3/"
fi
rsync -av --progress --delete "$DIR" "/home/fool/Documents/Games/Baldurs Gate 3/"
```

Any advice on how to get rsync to work with these spaces?

1 Answer

Answered By TechHelp123 On

It seems like those backslashes you added might be the issue. The quotes around your parameters should handle the spaces just fine without extra escapes. Try running the command without those backslashes.

CuriousCoder42 -

That works, thanks!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.