a guest Oct 13th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- import os
- # Replace with the absolute path of you directory
- dir_path = '/Users/arpit/Documents/work/om/Data/McCutchionAndBhowmick_Songs'
- all_files = os.listdir(dir_path)
- print("Shake that booty!")
- for af in all_files:
- with open(dir_path + "/" + af, 'r') as af_file:
- counter = 1
- new_dir_name = af.split(".")
- new_dir_path = dir_path + "/" + new_dir_name
- if not os.path.isdir(new_dir_path):
- split_paras = af_file.read().split("\n\n")
- for sp in split_paras:
- if sp.strip():
- new_file_path = new_dir_path + "/" + str(counter) + "_grinded.txt"
- with open(new_file_path, "w+") as grinded_file:
- counter += 1
- print("Grinding finished!")
RAW Paste Data