python list files and folder using tkinter

Pascal B barpasc at yahoo.com
Sun Dec 5 10:46:21 EST 2021


Hello,
I have already posted a message some time ago for this app. Since then, I didn't code in python or made any changes. I think before getting further with functionnalities a few things or the whole thing need to be changed.
For exemple, it would need a button to pick folders and maybe ask if the csv resulting file can be saved in the same folder.
And more important, files are listing ok in windows but not in linux after running it a few times.
https://github.com/barpasc/listfiles
code extract without indentation, see source script on github

elif vvchkboxF == 1: 
|   # *** FOLDERS AND FILES ONLY *** |
|


|   for root, dirs, files in os.walk(Lpath, topdown=False): |
|


|   ### calcul taille dossier |
|


|   size = 0 |
|


|   for x, y, z in os.walk(root): |
|


|   for i in z: |
|


|   ftmp_che = x + os.sep + i |
|


|   f_size += os.path.getsize(ftmp_che) |
|


|   ### ecriture taille dossier |
|


|   counter = root.count(os.path.sep) - counterPath |
|


|   vfile_name = root |
|


|   vfile_name = vfile_name + os.path.sep |
|


|   vfile_name = os.path.split(os.path.dirname(vfile_name))[1] |
|


|   vfile_name += os.path.sep |
|


|   if counter <= f_vscale: |
|


|   csv_contents += "%s;%s;%.0f;%.2f;%.2f;%.2f;%s\n" % (root, vfile_name, f_size, f_size/1024, f_size/1048576,f_size/1073741824, "folder") |
|


|  
 |
|


|   ### calcul +ecriture taille fichier |
|


|   for f in os.listdir(Lpath): |
|


|   path = os.path.join(Lpath, f) |
|


|   if os.path.isfile(path): |
|


|   f_size = 0 |
|


|   f_size = os.path.getsize(path) |
|


|   csv_contents += "%s;%s;%.0f;%.2f;%.2f;%.2f;%s\n" % (path, f, f_size, f_size/1024, f_size/1048576,f_size/1073741824, "file") |
|


|  
 |
|


|   fx_writeCSV_str(csv_contents) |
|

  print("job adv listing files ok")


More information about the Python-list mailing list