-
Notifications
You must be signed in to change notification settings - Fork 0
/
rm_headers.py
24 lines (20 loc) · 918 Bytes
/
rm_headers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
def remove_first_n_lines(file_path, n=1):
"""Remove the first n lines from the specified file."""
with open(file_path, 'r') as file:
lines = file.readlines()
# Write back the lines excluding the first n lines
with open(file_path, 'w') as file:
file.writelines(lines[n:])
def process_directory(directory):
"""Process all .c files in the given directory and its subdirectories."""
for root, _, files in os.walk(directory):
for file in files:
if file.endswith('.c'):
file_path = os.path.join(root, file)
print(f"Processing file: {file_path}")
remove_first_n_lines(file_path)
if __name__ == "__main__":
# Specify the directory you want to process
target_directory = '/Users/tristan/Documents/minishell/srcs/' # Change this to your target directory
process_directory(target_directory)