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
-
Make sure you have Go installed.
-
Clone this repository or copy the source file.
-
Build the binary depending on your platform:
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:
-
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.
-
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:
- List all files (excluding those ignored).
- Ask you which files to include using the selection syntax.
- 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.