buster / data /remove_extra_notion_titles.py
Louis-François Bouchard
16k prompt (#19)
0b9f9a6 unverified
raw
history blame contribute delete
593 Bytes
import os
# Set your folder path
folder_path = "/Users/louis/Downloads/llm_course"
# Get all filenames from the folder
filenames = os.listdir(folder_path)
# Iterate through each filename
for filename in filenames:
last_space_index = filename.rfind(" ")
# If a space is found, rename the file
if last_space_index != -1:
new_filename = filename[:last_space_index]
old_path = os.path.join(folder_path, filename)
new_path = os.path.join(folder_path, new_filename)
os.rename(old_path, new_path)
print(f"Renamed {filename} to {new_filename}")