What's the best way in Python to find all empty (zero byte) files, recursively, from a given directory? I could use os.walk and stat each file, but that seems very inefficient. Thanks.
2 Answers
I'm not sure how you'd get more efficient than os.walk and stat since that's fundamentally what you're doing. You could use some external command/service through Python's subprocess.Popen but then that's hardly "in python".
1 Comment
Dave Crumbacher
After doing some testing with os.walk and stat, it doesn't seem to be much different than the OS command "find <dir> -empty". Given my minimal expertise, I was thinking there may be a better way, but apparently not. Thanks for the quick response.
statthem?