Skip to content

Instantly share code, notes, and snippets.

View Mapagmataas1331's full-sized avatar
👀
cyou

Mapagmataas Mapagmataas1331

👀
cyou
View GitHub Profile
@Mapagmataas1331
Mapagmataas1331 / getFiles.py
Created October 13, 2023 19:23
This Python script is a file content extraction tool that lets you input a project directory, gather data from files within that directory, and save their content to one text file. It can handle both individual files and entire directories, and it's designed to gracefully handle non-text files, directories, or missing files.
import os
# Function to read the content of a file and return it as a string
def read_file_content(file_path):
try:
with open(file_path, 'r', encoding='utf-8', errors='ignore') as file:
content = file.read()
return content
except (UnicodeDecodeError, IsADirectoryError, FileNotFoundError):
# Handle non-text files or directories, and missing files