FileMerger

command module
v0.0.0-...-49afb92 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2025 License: MIT Imports: 7 Imported by: 0

README

File Merger Tool

A lightweight command-line tool written in Go that helps you collect file contents from a project directory into a single data.txt file. You can interactively choose which files to include, apply ignore rules, and even use flexible selection syntax.


Features

  • Recursive file listing – Lists all files under a project directory.

  • Ignore support – Skips files and directories defined in a .ignore file (similar to .gitignore).

  • Negation rules – Use !pattern in .ignore to explicitly re-include certain files.

  • Selection syntax

    • 0,3,5 → choose specific files by index
    • * → choose all files
    • * !1,2 → choose all files except indices 1 and 2
    • * !1-3 → choose all files except indices 1 through 3 (range support)
  • Output format – Writes selected files into data.txt with clear headers:

    // path/to/file.ext
    file content here...
    
    // another/file.ext
    more content...
    

Installation

  1. Make sure you have Go installed.

  2. Clone this repository or copy the source file.

  3. Build the binary depending on your platform:

    • Linux/macOS:

      go build -o filemerger main.go
      
    • Windows:

      go build -o filemerger.exe main.go
      ```
      

Usage

After building, the compiled binary (filemerger.exe on Windows, filemerger on Linux/macOS) will be created in the current folder. To run it, you have two options:

  1. Run from the same folder – Keep the binary in your project folder and run:

    ./filemerger
    

    ⚠️ Make sure the binary is present in the same folder where you run the command.

  2. Add to PATH – To reuse the tool from anywhere:

    • Move the binary to a directory that is already in your system PATH (e.g., /usr/local/bin on Linux/macOS or a folder listed in the Windows PATH environment variable).

    • Then you can run it directly from any working directory:

      filemerger
      

The tool will then:

  1. List all files (excluding those ignored).
  2. Ask you which files to include using the selection syntax.
  3. Write the chosen files into data.txt in the current working directory.

The .ignore File

Place a .ignore file in the root of your project directory to control which files and directories should be skipped.

Examples:

# Ignore all log files
*.log

# Ignore a directory
build/

# Ignore all .exe files
*.exe

# Re-include one specific file
!important.log
!build/config.yaml

Examples

Select all files
*
Select specific files
0,2,5
Select all except some
* !1,3
Select all except a range
* !2-5

Output Example

If you selected two files (main.go and README.md), your data.txt will look like this:

// main.go
package main

func main() {
    println("Hello, world")
}

// README.md
# Project Title
Some description here.

License

This project is released under the MIT License. You are free to use, modify, and distribute it.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL