Advertisement
Guest User

Untitled

a guest
Apr 21st, 2017
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import os, shutil
  2.  
  3. def flipchunk(iterable, inc):
  4.   chunks = [iterable[x:x+inc] for x in range(0, len(iterable), inc)]
  5.   c2 = [x[::-1] for x in chunks]
  6.   return c2
  7.  
  8. def swap2bik(infile):
  9.   with open(infile, "rb") as inf:
  10.     data = inf.read()
  11.   flipped  = flipchunk(data, 4)
  12.   output = b"".join(flipped)
  13.   fname = infile.replace("bikswap", "bik")
  14.   with open(fname, "wb") as ouf:
  15.     ouf.write(output)
  16.  
  17. def main(infolder):
  18.   os.chdir(infolder)
  19.   bikswaps = [x for x in os.listdir(os.getcwd()) if x.endswith(".bikswap")]
  20.   for bikswap in bikswaps:
  21.     swap2bik(bikswap)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement