Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Any idea?
#1
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:

rsync -an /home/jer/.*/ /Temp

After some research, I tried the following syntax:

rsync -an /home/jer/.[^.]*/ /Temp
This 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!
Reply


Messages In This Thread
Any idea? - by Cloved1945 - Sep-12-2024, 07:42 AM
RE: Any idea? - by Pedroski55 - Sep-12-2024, 05:33 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020