A powerful, cross-platform Terminal User Interface (TUI) application written in Rust for copying files and folders with advanced content and path replacement capabilities.
- Recursive Copy: deeply copies directory structures.
- Smart Replacements:
- Path Replacement: Rename directories and files during the copy process.
- Content Replacement: Find and replace text within files.
- Filtering:
- Filter by file extensions (e.g.,
*.rs,*.txt). - Filter by specific filenames.
- Filter by file extensions (e.g.,
- Interactive TUI:
- Directory Explorer: Navigate your filesystem to select source directories.
- File Preview: See file contents before copying.
- Live Configuration: Edit replacement rules and notes on the fly.
- Save & Load: Persist your configuration templates (
config.json) for reusable workflows. - Safety: Prevents overwriting existing destination directories to avoid data loss.
- Performance: Uses multi-threading to keep the UI responsive during large copy operations.
Ensure you have Rust installed. If not, install it from rustup.rs.
-
Clone the repository:
git clone <repository-url> cd file-folder-copy-replace
-
Build the project:
cargo build --release
-
Run: The binary will be located in
target/release/../target/release/file-folder-copy-replace
Or run directly with Cargo:
cargo run
The application is divided into several key areas:
- Source Directory: The path you want to copy from.
- Source Directory Explorer: A navigable list of folders to help you find your source.
- Files in Folder: Shows files in the currently selected explorer folder.
- File Preview: Displays the content of the selected file.
- Replacement Mapping: Where you define your copy/replace rules.
- Generated Destination Directory: The calculated output path based on your rules.
- Free Hand Notes: A scratchpad for your own notes (saved with the config).
- Buttons: Save, Load, Help, and Copy Replace.
Tab/BackTab: Cycle focus between different sections.Enter: Select an item (Explorer) or trigger a button.Arrow Keys: Navigate lists or move cursor in text fields.e: Enter "Editing Mode" for text fields (Source Input, Mapping, Notes).Esc: Exit "Editing Mode" or close popups (Help, Error).q: Quit the application (when in Normal mode).
Define rules in the "Replacement Mapping" text area.
Syntax: Value --ConfigurationType
Format: OldValue=NewValue --Type
--path-only: Replaces text in directory and file paths/names only.--files-only: Replaces text inside the file contents only.--path-files: Replaces text in BOTH paths and file contents.
Examples:
production=stage --path-only
v1.0=v2.0 --path-files
TODO=DONE --files-only
Format: Value1, Value2, ... --Type
--file-types: Only process files with these extensions.--file-names: Only process files with these exact names.
Examples:
*.rs, *.toml, *.md --file-types
config.json, Dockerfile --file-names
For those learning Rust, here is a high-level overview of the codebase:
src/main.rs: The entry point. Sets up the terminal (Crossterm), initializes theAppstate, and runs the main event loop.src/app.rs: Holds the application state (struct App). Handles user input events (on_key,on_mouse) and updates the state accordingly.src/ui.rs: Responsible for rendering the TUI usingratatui. It defines the layout and draws widgets based on the currentAppstate.src/logic.rs: Contains the core business logic:perform_copy_replace: The heavy lifting of walking directories, reading files, replacing text, and writing to the destination.read_directory: Helper to list files for the explorer.Config&Template: Structs for parsing rules and saving/loading JSON.
Check the source code! We've added detailed comments explaining various Rust concepts used in this project, such as:
- Structs & Enums
- Result & Option handling
- Multi-threading with Channels (
mpsc) - File I/O & Iterators
- Closures
- Serde (Serialization/Deserialization)