Nies221 OP ,
@Nies221@lemmy.world avatar

To get the size of archives and folders:
os.stat(filename).st_size # for folders you have to use it together with os.walk()

To get the list of files inside an archive I use the zipfile, rarfile and tarfile modules.
For the file type, I either extract the extension from the name or I use a bash command via subprocess:file --mime-type filepath
subprocess is used if there is no extension (as often happens with text files).

I preferred to use subprocess to avoid having to increase the number of dependencies needed.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • [email protected]
  • All magazines