Skip to content

Instantly share code, notes, and snippets.

@fwarren
Last active October 5, 2017 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fwarren/7d01a7a98570a917d4a6219bc2fb4778 to your computer and use it in GitHub Desktop.
Save fwarren/7d01a7a98570a917d4a6219bc2fb4778 to your computer and use it in GitHub Desktop.
Find all files in filetree that have null signatures
#!/usr/bin/python2
# Import the os module, for the os.walk function
import os
# Set the directory you want to start from
rootDir = '/cygdrive/d/Tank/Shares'
for dirName, subdirList, fileList in os.walk(rootDir):
for fname in fileList:
with open('%s/%s' % (dirName,fname), "rb") as f:
if f.read(8) == '\x00\x00\x00\x00\x00\x00\x00\x00':
mytime = datetime.datetime.fromtimestamp(os.path.getmtime('%s/%s' % (dirName,fname))).strftime('%Y-%m-%d:%H:%M')
print('%s\t%s/%s' % (mytime,dirName,fname))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment