Advertisement
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(".")[0]
- new_dir_path = dir_path + "/" + new_dir_name
- if not os.path.isdir(new_dir_path):
- os.mkdir(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:
- grinded_file.write(sp.strip())
- grinded_file.close()
- counter += 1
- af_file.close()
- print("Grinding finished!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement