0

Im trying to copy directorys and files from

/var/media/KODI/connman to /storage/.cache/connman

Inside the connman folder is a file and another folder with a file inside

The problem im having is that only the folder and its file are being copied the file in the connman folder is not. the code im working on is:

        drive = xbmcaddon.Addon().getSetting('Drive')
        connman = ('connman/')
        src_network = ('/storage/.cache/')


        for file_or_dir in os.listdir(drive + connman):
            path = os.path.join(drive + connman,file_or_dir)
            if os.path.isdir(path):
                dir = file_or_dir
                src = os.path.join(drive + connman,dir)
                dst = os.path.join(src_network,dir)
                try:
                    copytree(src,dst)
                except Exception as e:
                    log(("copytree",e,src,dst))
Zain Ul Abidin
  • 2,467
  • 1
  • 17
  • 29
kodi User
  • 23
  • 5
  • 1
    Does this answer your question? [How do I copy an entire directory of files into an existing directory using Python?](https://stackoverflow.com/questions/1868714/how-do-i-copy-an-entire-directory-of-files-into-an-existing-directory-using-pyth) – Tzane Nov 23 '21 at 07:33

1 Answers1

0

Try this.

from distutils.dir_util import copy_tree
copy_tree("/source_folder", "/target_folder")
Anupam Chand
  • 2,209
  • 1
  • 5
  • 14