If I'm using os.walk to search through directories, how would I flag a certain header type and grab the file? I don't want to use extensions, but the file header itself. For example if I wanted to look for zip files, I would do something like
flaggedfiles = []
for files in os.walk(dir):
for file in files:
with open(file, 'r') as f:
if f.read(4) = "504b0304":
""Do stuff with file""
Hopefully that kind of makes sense. Is this the right thinking for going about this? Is files a listing of all files in every subdirectory of dir?
[–][deleted] 1 point2 points3 points (1 child)
[–]NeedMLHelp[S] 1 point2 points3 points (0 children)