<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>chris' random ramblings (Posts about windows)</title><link>https://atlee.ca/</link><description></description><atom:link href="https://atlee.ca/categories/windows.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><lastBuildDate>Sat, 22 Feb 2025 20:04:32 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Getting free diskspace in python, on Windows</title><link>https://atlee.ca/posts/blog20100510getting-free-diskspace-in-python-on-windows/</link><dc:creator>chris</dc:creator><description>&lt;p&gt;Amazingly, one of the most popular links on this site is the quick tip, &lt;a href="https://atlee.ca/blog/2008/02/23/getting-free-diskspace-in-python/"&gt;Getting free diskspace in python.&lt;/a&gt;


One of the comments shows that this method doesn't work on Windows.  Here's a version that does:



&lt;/p&gt;&lt;pre lang="python"&gt;import win32file

def freespace(p):
    """
    Returns the number of free bytes on the drive that ``p`` is on
    """
    secsPerClus, bytesPerSec, nFreeClus, totClus = win32file.GetDiskFreeSpace(p)
    return secsPerClus * bytesPerSec * nFreeClus
&lt;/pre&gt;



The win32file module is part of the &lt;a href="http://sourceforge.net/projects/pywin32/"&gt;pywin32&lt;/a&gt; extension module.</description><category>python</category><category>technology</category><category>tips</category><category>windows</category><guid>https://atlee.ca/posts/blog20100510getting-free-diskspace-in-python-on-windows/</guid><pubDate>Tue, 11 May 2010 02:00:53 GMT</pubDate></item></channel></rss>