Copy files and catalogs with bar progress [don't work]

I try write coping with folder.
Coping works, but progress bar no and I don’t know what doing …

import shutil
import os
import itertools

from time import sleep
from tqdm import tqdm

# path to source directory
src_dir = '/home/piotr/.cache/'

# path to destination directory
dest_dir = '/home/piotr/.cache/0/'

# getting all the files in the source directory
files = os.listdir('/home/piotr/.cache/')

# progress bar start
for files in itertools.count():
# progress bar finish
shutil.copytree('/home/piotr/.cache/', '/home/piotr/.cache/0/')

You should be seeing an error message something like:

TypeError: ‘str’ object cannot be interpreted as an integer

It is because of the following line:


The range function accepts 3 arguments that are all integers. You are supplying the string "files" to it which is why it errors out.

You are not using the tqdm function correctly. I suggest reviewing the documenation for it to see what you are doing wrong.

Plus, this is just going to run separately from any progress bar. You would need to just use shutil.copy for each file within the for loop to get closer to what you want.