Article 4YSED python 3 tqdm module deleting a directory

python 3 tqdm module deleting a directory

by
lancebermudez
from LinuxQuestions.org on (#4YSED)
Want a progress bar for deleting a directory

errror i get is
Code:/home/lance/plex/powershell
Python Version: 3.7.5 (default, Nov 20 2019, 09:21:52)
[GCC 9.2.1 20191008]
OS Platform: linux
/home/lance/Documents
Removing Old Files

0%| | 0/100 [00:00<?, ?it/s]
0%| | 0/100 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/home/lance/plex/powershell/PythonCopyFiles.py", line 30, in <module>
rmtree('/home/lance/Documents/Music')
File "/usr/lib/python3.7/shutil.py", line 485, in rmtree
onerror(os.lstat, path, sys.exc_info())
File "/usr/lib/python3.7/shutil.py", line 483, in rmtree
orig_st = os.lstat(path)
FileNotFoundError: [Errno 2] No such file or directory: '/home/lance/Documents/Music'my python code is
Code:from os import chdir # os.chdir
from os import getcwd # os.getcwd
from os import getenv # os.getenv
from os.path import isdir # os.path.isdir
from shutil import rmtree # shutil.rmtree
from sys import version
from sys import platform
from tqdm import tqdm
print(getcwd())
print('Python Version: ', version)
print('OS Platform: ', platform)
if platform == 'linux':
chdir(join(getenv('HOME'), 'Documents'))
print(getcwd())
if isdir('/home/lance/Documents/Music'):
print('Removing Old Files')
for i in tqdm(range(0,100)):
rmtree('/home/lance/Documents/Music')latest?d=yIl2AUoC8zA latest?i=1zxpNWphrJ8:NdOx1Tu9JUM:F7zBnMy latest?i=1zxpNWphrJ8:NdOx1Tu9JUM:V_sGLiP latest?d=qj6IDK7rITs latest?i=1zxpNWphrJ8:NdOx1Tu9JUM:gIN9vFw1zxpNWphrJ8
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments