Gfy

bad_nfos.py

Gfy
Oct 16th, 2017
95
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3.  
  4. import os
  5. import sys
  6. import shutil
  7.  
  8. if __name__ == "__main__":
  9.     tomove = []
  10.     for dirpath, dirnames, filenames in os.walk("."):
  11.         for filename in filenames:
  12.             if filename.endswith(".nfo"):
  13.                 f = os.path.join(dirpath, filename)
  14.                 with open(f, "rb") as nfofile:
  15.                     data = nfofile.read()
  16.                    
  17.                     # E2 96 84
  18.                     #if "\xE2" in data or "\x96" in data or "\x84" in data:
  19.                     #   print(dirpath)
  20.                     #   tomove.append((dirpath, os.path.join("0tofixnfo", dirpath)))
  21.    
  22.                     if data[0:3] == b"ID3":
  23.                         tomove.append((dirpath, "_mp3nfos"))
  24.    
  25.     for (dfrom, to) in tomove:
  26.         shutil.move(dfrom, to)
RAW Paste Data