Skip to main content

Use files-flattener to flatten your whole structured code project into a single file.

Project description

Files Flattener

This repository contains implementations for recursively reading all files in a specified directory and outputting their filenames and contents to a specified output file.

Why do I need this?

Imagine you are working on a project and need to share the project structure and file contents with a collaborator or an AI platform for analysis. Instead of manually copying and pasting each file's content, you can use the files_flattener.py script to generate a single file with all the necessary information. This consolidated file can then be easily shared, ensuring that the recipient has all the context needed to understand the project.

Example

Assume you have the following directory structure:


|
|--folder1
| |--file1.txt
| |--file2.txt
|--file3.txt

And you have an .ignore file in the root directory with the following content:


folder1/file2.txt

# Exclude itself

.ignore

Running the implementation will process the files, ignoring folder1/file2.txt and .ignore itself as specified in the .ignore file. The output file will contain the contents of the remaining files in the following format:


**folder1/file1.txt:**

[...file1.txt's content...]

**file3.txt:**

[...file3.txt's content...]

Getting Started

Python

Usage

  1. Ensure you have Python installed on your system.

  2. Install the required dependencies by running:

    pip install -r requirements.txt
    
  3. Run the script using the command:

    python files_flattener.py <directory> <output_file> [<ignore_file>]
    

Parameters

  • <directory>: The path of the directory containing the files to be flattened.
  • <output_file>: The path of the output file where the contents of the files will be written.
  • [<ignore_file>]: (Optional) The path to a file containing patterns of files to ignore. If not provided, the script will look for a '.ignore' file in the specified directory. If the '.ignore' file is not found, no files will be ignored.

TODO

  • Add dry-run mode to preview the output before writing to the file.
  • Make a web app based on Vue3.
  • Use .ignore to exclude or include files for flattening.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

files_flattener-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

files_flattener-0.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file files_flattener-0.1.0.tar.gz.

File metadata

  • Download URL: files_flattener-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.6

File hashes

Hashes for files_flattener-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5dc2c29a52ede150a2ecc00a9925b578f240bce8f77c5ecec80ad23d17a4cfa5
MD5 eec036ca8292701608fd2ce3d847cc34
BLAKE2b-256 799b456191e487b390002b42173905380d98770cb47669e2e8844a1cf4ad572c

See more details on using hashes here.

File details

Details for the file files_flattener-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for files_flattener-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78bf8a9a713905431131c9c08a90949ee493e0606d3105a665c6728ba1b9e70d
MD5 8adfd5a03cd1333848d0995432e1d427
BLAKE2b-256 54873eaab146c121082bfb816608c6f31d209a1256286af48d0dcbac86c6a61c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page