Sep-12-2024, 07:42 AM
New to Python but not to coding.
I would like to copy only the hidden files and folders in my home directory with rsync from a Python script.
The issues is that using a .* 101 games after the source directory name (/home/jer/.*) causes an rsync error when executed from Python.
However, in the Linux terminal, this statement works fine:
After some research, I tried the following syntax:
Below is my relevant code snippet:
I would like to copy only the hidden files and folders in my home directory with rsync from a Python script.
The issues is that using a .* 101 games after the source directory name (/home/jer/.*) causes an rsync error when executed from Python.
However, in the Linux terminal, this statement works fine:
rsync -an /home/jer/.*/ /Temp
After some research, I tried the following syntax:
rsync -an /home/jer/.[^.]*/ /TempThis also causes an rsync error but in the Linux terminal also works fine.
Below is my relevant code snippet:
bk_args = "-avn" bk_src_dir = "/home/jer/.[^.]*/" bk_tar_dir = "/mnt/md0" bk_options = ['--itemize-changes=%i%f', '--info=stats2', '--progress'] try: subprocess.run(["rsync", bk_args, *bk_options, bk_src_dir, bk_tar_dir])This causes the following rsync error:
sending incremental file list rsync: [sender] change_dir "/home/jer/.[^.]*" failed: No such file or directory (2)I have tried various combinations of escaping ".*" without success so I thought it was time to come to the mountain for some ideas!