Help, please, make a progress bar for the folder cleaning process. I clear the folder with this command

shutil.rmtree('c:/temp', ignore_errors=True,) 

For this there are modules tqdm and progressbar, but how to adapt them for this task?

  • If I were you, I would first clean all the files in the folder and then the folder itself. And the number of files in the folder This is actually a progress bar for each deleted file -1 to the progress bar. - Gleb
  • You can try to os.rmdir , os.unlink with your versions, which are called by progress_bar.update() . If the changes from launch to launch are expected to be relatively small, then you can save the total number of folders, other entries, the elapsed time from the previous launch, in order to estimate how many more entries you need to delete / how long it will take. - jfs
  • I was able to do the function that deletes files from the beginning, then using os.rmdir and os.remove, but I don’t understand how to move the progress bar - Kot_Andrei
  • “I don’t understand how to move the progress bar” - this can be asked as a separate Stack Overflow (for a larger circle of people to approach) with a simple example: for _ in range(100): if random.random() < 0.1: i+=1; t.update(i) for _ in range(100): if random.random() < 0.1: i+=1; t.update(i) - jfs

0