-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_files.py
31 lines (24 loc) · 1.11 KB
/
print_files.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
25
26
27
28
29
30
31
import os
def print_file_contents(directory):
for root, dirs, files in os.walk(directory):
# Skip the __pycache__ and .git directories
dirs[:] = [d for d in dirs if d not in ('__pycache__', '.git')]
for filename in files:
# Skip binary files like .pyc and .git files
if filename.endswith('.pyc') or filename == '.git':
continue
# Get the full path of the file
filepath = os.path.join(root, filename)
# Print the filename
print(f"\n{'='*40}\nFile: {filepath}\n{'='*40}")
# Print the contents of the file
try:
with open(filepath, 'r') as file:
print(file.read())
except Exception as e:
print(f"Could not read {filepath}. Error: {e}")
if __name__ == "__main__":
# Define the directory containing your project files
project_directory = '.' # Update this to the correct path if necessary
# Print the contents of each file in the directory
print_file_contents(project_directory)