How to get the size of a file (Python script)?

  • 27 February 2020
  • 2 replies
  • 5 views

  1. Set the file Path and name into a variable.
  2. Escape the backslash characters by replacing """ with "\"
  3. Run the following python script
  4. 25706i5E10B05998A2602D.jpg
  5. Note that the file path and name must be placed within double quotes to avoid syntax error.
  6. The resulting file size will be in bytes.
  7. To convert the file size to MB, do a division by 1024.

 

 


2 replies

Very well. Thank you!

Badge +2

How to solve it?

Reply