Colemen_copy is a robust file copying utility written in Rust that provides similar functionality to Microsoft's Robocopy (Robust File Copy) but works across multiple platforms including Linux, macOS, and Windows.
Tiny Note: I included the .vscode folder, it has a tasks.json file, which offers a super lazy way to compile the program through vscode. If you don't want it, delete that shit, it is not critical to the software in any way.
- Cross-Platform Compatibility: Works on Linux, macOS, and Windows
- Directory Mirroring: Complete directory tree synchronization
- Robust Copying: Automatic retries for failed operations
- File Filtering: Include/exclude files based on patterns
- Progress Tracking: Real-time copying progress information
- Detailed Logging: Comprehensive logging of all operations
- Move Operations: Support for moving files instead of just copying
- Attribute Preservation: Maintains file timestamps and attributes
- Empty Files Mode: Create zero-byte copies to recreate directory structures efficiently
- Child Directory Mode: Process only direct child folders of source path
- Secure Deletion: Securely overwrite files before deletion to prevent data recovery
-
Ensure you have Rust and Cargo installed:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Clone the repository:
git clone https://github.com/r146023/colemen_copy.git cd colemen_copy -
Build the project:
cargo build --release
-
The executable will be available at
target/release/colemen_copy
- Download this repository
- Extract it
- Copy the executable out of the "executables" folder.
- Paste it wherever you want and call it from your terminal. (You can delete the repository folder, if you want.)
- You are good to go!
colemen_copy <source> <destination> [file_pattern] [options]
# Copy all files from source to destination
./colemen_copy /path/to/source /path/to/destination
# Copy all .jpg files
./colemen_copy /path/to/source /path/to/destination *.jpg
# Mirror a directory tree, including empty directories
./colemen_copy /path/to/source /path/to/destination /MIR
# Copy with progress display, retries, and logging
./colemen_copy /path/to/source /path/to/destination /Z /R:5 /W:10 /LOG:copy_log.txt
# Create empty (zero-byte) copies of all files
./colemen_copy /path/to/source /path/to/destination /EMPTY /E
# Process only direct child folders of the source directory
./colemen_copy /path/to/source /path/to/destination /CHILDONLY
# Securely delete files in destination that don't exist in source
./colemen_copy /path/to/source /path/to/destination /PURGE /SHRED| Option | Description |
|---|---|
/S |
Copy subdirectories, but not empty ones |
/E |
Copy subdirectories, including empty ones |
/Z |
Copy files in restartable mode (slower but more robust) |
/B |
Copy files in Backup mode (overrides file/folder permissions) |
/PURGE |
Delete destination files/folders that no longer exist in source |
/MIR |
Mirror directory tree (like /PURGE plus all subdirectories) |
/MOV |
Move files (delete from source after copying) |
/MOVE |
Move files and directories (delete from source after copying) |
/A+:[RASHCNETO] |
Add specified attributes to copied files |
/A-:[RASHCNETO] |
Remove specified attributes from copied files |
/MT[:n] |
Multithreaded copying with n threads (default is 8) |
/R:n |
Number of retries on failed copies (default is 1 million) |
/W:n |
Wait time between retries in seconds (default is 30) |
/LOG:file |
Output log to file |
/L |
List only - don't copy, timestamp or delete any files |
/NP |
No progress - don't display % copied |
/NFL |
No file list - don't log file names |
/EMPTY |
Create empty (zero-byte) copies of files |
/CHILDONLY |
Process only direct child folders of source path |
/SHRED |
Securely overwrite files before deletion |
Colemen_copy supports simple wildcard patterns:
*- Matches any number of any characters*word*- Matches any string containing "word"word*- Matches any string starting with "word"*word- Matches any string ending with "word"*.ext- Matches any file with the extension ".ext"
When Colemen_copy runs, it provides statistics in the following format:
-------------------------------------------------------------------------------
Colemen_copy - Finished: HH:MM:SS
Source: /path/to/source
Destination: /path/to/destination
Statistics:
Directories: X
Files: Y
Bytes: Z
Directories skipped: A
Files skipped: B
Files failed: C
Directories removed: D
Files removed: E
Elapsed time: N seconds
-------------------------------------------------------------------------------
To make the destination exactly match the source (including deleting files in destination that don't exist in source):
./colemen_copy /path/to/source /path/to/destination /MIRFor faster operations on multi-core systems:
./colemen_copy /path/to/source /path/to/destination /MT:16When copying across unreliable networks:
./colemen_copy /path/to/source /path/to/destination /Z /R:100 /W:30To move files instead of copying them:
./colemen_copy /path/to/source /path/to/destination /MOVTo copy only specific file types:
./colemen_copy /path/to/source /path/to/destination *.jpg *.png *.gif /SWhen removing files (either with /PURGE, /MIR, or when moving files with /MOV or /MOVE), you can ensure the files are securely deleted to prevent data recovery:
./colemen_copy /path/to/source /path/to/destination /MIR /SHREDNote that secure deletion significantly increases the time required for operations that delete files, as each file must be overwritten multiple times before deletion.
To recreate a directory structure without copying the actual file contents (useful for testing or planning):
./colemen_copy /path/to/source /path/to/destination /EMPTY /EThis creates all the same directories and files, but the files are empty (zero bytes), saving disk space while preserving the structure.
To recreate a directory structure without copying the actual file contents (useful for testing or planning):
./colemen_copy /path/to/source /path/to/destination /EMPTY /EThe /EMPTY option is particularly useful for:
- Testing directory structures: Verify paths and permissions without transferring large amounts of data
- Planning migrations: Set up the target structure to analyze space requirements and permissions
- Template creation: Create skeleton file structures that will be populated later
- Backup preparation: Create a directory structure quickly before prioritizing which files to back up
- Low bandwidth environments: When you need to recreate a file structure remotely but have limited bandwidth
To process only the direct child folders of the source path:
./colemen_copy /path/to/source /path/to/destination /CHILDONLYThis option is useful when:
- Organizing collections of folders that need individual processing
- Working with media libraries where each subfolder is a separate project or album
- Batch processing a set of distinct folders without recursing into their hierarchies
- Handling first-level categorized data that needs to be copied separately
Lets say this is your source directory:
Source/
├── ProjectA/
│ ├── docs/
│ │ └── manual.pdf
│ ├── src/
│ │ ├── main.c
│ │ └── helper.c
│ └── README.md
├── ProjectB/
│ ├── images/
│ │ ├── logo.png
│ ├── website/
│ │ └── index.html
│ └── README.md
├── ProjectC/
│ ├── data/
│ │ └── sample.csv
│ └── scripts/
│ └── analyze.py
└── ThisFileIsIgnored.md
This is the destination:
Destination/
├── ProjectA/
│ ├── docs/
│ │ └── manual.pdf
│ ├── src/
│ │ ├── main.c
│ │ └── helper.c
│ └── README.md
├── EXTRA_THING/
├── ProjectB/
│ ├── images/
│ │ ├── logo.png
│ │ └── banner.jpg
│ ├── website/
│ │ └── index.html
│ └── README.md
When you run the command:
./colemen_copy /path/to/Source /path/to/Destination /MIR /CHILDONLYIt will go through ProjectA,ProjectB and ProjectC to synchronize everything within those directories.
It will completely ignore ThisFileIsIgnored.md and it will NOT delete or modify the EXTRA_THING directory in the destination.
The banner.jpg in ProjectB will be deleted because it does not exist in the source.
This is very useful for synchronizing a folder where each child needs to be handled individually.
- Advantages: Cross-platform compatibility, Rust safety guarantees
- Limitations: Some advanced Robocopy features may not be implemented
- Advantages: Windows support, Robocopy-like syntax for Windows users
- Limitations: Not as optimized for network transfers as rsync
Colemen_copy includes comprehensive error handling and will:
- Retry failed operations according to specified retry parameters
- Log all errors encountered during copying
- Provide a summary of successful and failed operations
- Return appropriate exit codes for scripting
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by Microsoft's Robocopy utility
- Built with Rust for performance and safety
- Thanks to all contributors who have helped improve this tool
Colemen_copy is not affiliated with Microsoft or Robocopy. It is an independent implementation providing similar functionality.