0

I'm trying to write a simple script that looks at various files and manipulates them depending on file size, but I've tried both :

os.stat(path + fname).st_size

and

os.path.getsize(path + fname)

but both return a result of '0'. I'm running Kubuntu but the file system is NTFS formatted, could this be the problem, or does anyone have any reason why this may be happening?

** EDIT **

Somehow all my files have been emptied of all their data. Please ignore this, the filesize is being reported correct.

Martyn
  • 16,432
  • 24
  • 71
  • 104

1 Answers1

1

Don't build filenames as if they're plain strings. Use os.path helper functions. You could be missing a separator, or have double separators, or something.

Also try "validating" (or just plain inspecting) the filename, perhaps there are embedded NUL bytes that are causing confusion. See this comment to a different question.

Community
  • 1
  • 1
unwind
  • 391,730
  • 64
  • 469
  • 606