Skip to content

Instantly share code, notes, and snippets.

@silicontrip
Created June 6, 2018 00:45
Show Gist options
  • Select an option

  • Save silicontrip/8bfb4e548a33ddcac0061b4aeea49a21 to your computer and use it in GitHub Desktop.

Select an option

Save silicontrip/8bfb4e548a33ddcac0061b4aeea49a21 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import os
import fnmatch
import sys
import struct
import json
djdb={}
for root, dir, files in os.walk(sys.argv[1]):
for items in fnmatch.filter(files, "*.bpmdj1"):
djfn = root + os.sep + items
try:
f = open(djfn, "rb")
f.seek(4)
sid = ""
for id in range(32):
byte = f.read(1)
l = struct.unpack("B",byte)
sid += '{:02x}'.format(l[0])
djdb[sid] = djfn
finally:
f.close()
print json.dumps(djdb,indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment