<commit_before>#!/usr/bin/env python2.7

import os
import re
import shutil
import sys
from mutagen.easyid3 import EasyID3

emptyChars = re.compile(r"[(),.'\\\?\#]")
def toNeat(s):
  s = s.lower().replace(" ", "-").replace("&", "and")
  s = emptyChars.sub("", s)
  search = re.search("[^0-9a-z\-]", s)
  if search:
    print("Error: Unrecognized character in '" + s + "'")
    sys.exit(-42)
  return s

delete_dirs = []
for dirname, dirnames, filenames in os.walk('.'):
  # Move all the files to the root directory.
  for filename in filenames:
    ext = os.path.splitext(filename)[1]
    if ext == ".mp3":
      fullPath = os.path.join(dirname, filename)
      print("file: " + str(fullPath))

      try:
        audio = EasyID3(fullPath)
        title = audio['title'][0].decode()
        print("  title: " + title)
      except: title = None

      if not title:
        print("Error: title not found for '" + filename + "'")
        sys.exit(-42)

      neatTitle = toNeat(title)
      print("  neat-title: " + neatTitle)

      newFullPath = os.path.join(".", neatTitle + ext) # Remove subdirectories.
      print("  newFullPath: " + newFullPath)

      if newFullPath != fullPath:
        if os.path.isfile(newFullPath):
          print("Error: File exists: '" + newFullPath + "'")
          sys.exit(-42)

        os.rename(fullPath, newFullPath)
      os.chmod(newFullPath, 0644)
    elif ext == ".pdf":
      pass
    else:
      print("Error: Unrecognized file extension in '" + filename + "'")
      sys.exit(-42)

  # Delete all subdirectories.
  for subdirname in dirnames:
    delete_dirs.append(subdirname)

for d in delete_dirs:
  shutil.rmtree(d,ignore_errors=True)

print("\nComplete!")
<commit_msg>music: Replace '*' with '-'<commit_after>#!/usr/bin/env python2.7

import os
import re
import shutil
import sys
from mutagen.easyid3 import EasyID3

emptyChars = re.compile(r"[(),.'\\\?\#]")
def toNeat(s):
  s = s.lower().replace(" ","-").replace("&","and").replace("*","-")
  s = emptyChars.sub("", s)
  search = re.search("[^0-9a-z\-]", s)
  if search:
    print("Error: Unrecognized character in '" + s + "'")
    sys.exit(-42)
  return s

delete_dirs = []
for dirname, dirnames, filenames in os.walk('.'):
  # Move all the files to the root directory.
  for filename in filenames:
    ext = os.path.splitext(filename)[1]
    if ext == ".mp3":
      fullPath = os.path.join(dirname, filename)
      print("file: " + str(fullPath))

      try:
        audio = EasyID3(fullPath)
        title = audio['title'][0].decode()
        print("  title: " + title)
      except: title = None

      if not title:
        print("Error: title not found for '" + filename + "'")
        sys.exit(-42)

      neatTitle = toNeat(title)
      print("  neat-title: " + neatTitle)

      newFullPath = os.path.join(".", neatTitle + ext) # Remove subdirectories.
      print("  newFullPath: " + newFullPath)

      if newFullPath != fullPath:
        if os.path.isfile(newFullPath):
          print("Error: File exists: '" + newFullPath + "'")
          sys.exit(-42)

        os.rename(fullPath, newFullPath)
      os.chmod(newFullPath, 0644)
    elif ext == ".pdf":
      pass
    else:
      print("Error: Unrecognized file extension in '" + filename + "'")
      sys.exit(-42)

  # Delete all subdirectories.
  for subdirname in dirnames:
    delete_dirs.append(subdirname)

for d in delete_dirs:
  shutil.rmtree(d,ignore_errors=True)

print("\nComplete!")

{'fraction_non_alphanumeric': 0.16151401329095638, 'fraction_numerical': 0.012713088702687085, 'mean_word_length': 2.7225806451612904, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '333438', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1168, 'n_words': 286}