Skip to content
ju-gitPublic

About

Windows tool to copy files to 2 destinations at once

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ycopy

Copy files to two destinations at once, reading each source file only once.

Ycopy is a small native Windows tool written in Rust (edition 2024). Drop some files on the window, pick two destination folders, press Go!: every file is read a single time from the source and each chunk is written to both destinations. Handy when you back up the same files to two disks, or copy from a slow source (SD card, network share, old HDD) to two targets.

Ycopy main window

Features

  • Single read, two writes – each source file is read once, in 4 MiB chunks, and every chunk goes to both destinations. Memory use stays constant whatever the file size.
  • Native Win32 dialog – no web view, no runtime; the release executable is about 600 KB.
  • Drag & drop or browse – drop files on the list, or click it to open a multi-selection file picker.
  • Progress feedback – progress bar, then elapsed time, remaining time and copy speed in the status bar. The speed unit adapts itself (KB/s, MB/s, GB/s). Files disappear from the list as they are copied.
  • Throughput graph – a history of the copy speed is drawn under the progress bar, like the Windows copy dialog (it appears when the first copy starts).
  • Optional speed limit – the Options button opens a side panel with a "Limit copy rate" checkbox; once checked, enter a number and a unit (KB/s, MB/s, GB/s). The limit is a real cap on the throughput and is off unless the box is checked.
  • Cancel button – during a copy, Go! becomes Cancel; after confirmation the copy stops and partial files are removed.
  • Command-line mode – the same executable copies without opening a window when you pass files as arguments.
  • Multilingual – English, French, German, Spanish, Italian, Portuguese and Ukrainian, with a language selector in the status bar. Adding a language is a matter of adding one text file.
  • Safe by design – a file cannot be copied onto itself, partial copies are removed on error or cancellation, and file modification times are preserved.
  • Pre-allocated files – the final size of each destination file is reserved before writing, so the file system can allocate contiguous space.

Requirements

  • Windows 10 or later (x64).
  • To build: a recent stable Rust toolchain (MSVC target) and the Windows SDK, whose rc.exe is used to embed the icon and the manifest.

Build

cargo build --release

The executable is target/release/ycopy.exe.

Run the tests with:

cargo test

The icon (assets/ycopy.ico) is generated by a dependency-free example, only needed if you want to change the design:

rustc --edition 2024 -O examples/make_icon.rs -o target/make_icon.exe
target\make_icon.exe

Usage

Graphical interface

Run ycopy.exe without file arguments.

  1. Choose Destination 1 and Destination 2 (type a path or use the ... buttons). They must be different folders; missing folders are created.
  2. Drop files on the list, or click the list to browse. Folders are ignored.
  3. Optionally, click Options to open the side panel and limit the copy rate (check "Limit copy rate", then enter a value and a unit).
  4. Press Go! (enabled once both destinations are set). While the copy runs, the button reads Cancel; it asks for confirmation before stopping.

Files are copied one after the other. A file that fails is reported at the end and stays in the list so you can retry. Closing the window during a copy cancels it cleanly, without asking.

Command line

ycopy [OPTIONS] [FILE...]

  --dest1 DIR    first destination folder
  --dest2 DIR    second destination folder
  --lang CODE    interface language (en, fr, de, es, it, pt, uk)
  -h, --help     show this help
  -V, --version  show the version

Examples:

# Copy two files to two folders, no window
ycopy report.pdf photo.jpg --dest1 D:\Backup --dest2 E:\Backup

# Open the window with the destinations pre-filled, in German
ycopy --dest1 D:\Backup --dest2 E:\Backup --lang de

Exit codes: 0 success, 1 at least one file failed, 2 invalid usage.

The executable uses the Windows GUI subsystem, so when started from a terminal the prompt may come back before the copy has finished. Progress and messages are still printed to the console.

Language

The language is chosen, in this order, from:

  1. --lang CODE
  2. the YCOPY_LANG environment variable
  3. the Windows user locale
  4. English, as a fallback

The selector in the status bar changes the language immediately. The choice is deliberately not saved: the next launch starts again from the rules above.

Project layout

src/
  main.rs      entry point: GUI or command line
  lib.rs       shared helpers
  copier.rs    copy engine (no UI, no translation dependency)
  gui.rs       main dialog (native-windows-gui)
  cli.rs       argument parsing and command-line run
  i18n.rs      translations loaded from locales/*.txt
  format.rs    duration / speed formatting (adaptive unit)
  graph.rs     throughput history behind the graph
  platform.rs  the few Win32 calls used outside the GUI toolkit (incl. graph drawing)
locales/       en, fr, de, es, it, pt, uk (key = value files)
assets/        icon, manifest and resource script
examples/      icon generator
doc/           screenshot and AI-assisted development log

Adding a language

  1. Copy locales/en.txt to locales/<code>.txt and translate the values (keep the keys and the {0}, {1} placeholders).
  2. Add the variant to Lang in src/i18n.rs (code, native name, include_str!).

A unit test fails if a language is missing a key or has a different set of placeholders than English.

Design notes

  • The reported speed is the source read throughput: each byte read is written twice, so the amount written is double.
  • The remaining time is the average speed since the start applied to the bytes left.
  • The speed limit applies to that same source throughput. It is read when the copy starts; the pacing does not make up for time lost to a slow disk, so the limit is a cap, not an average to catch up on. When a limit is set, chunks shrink to about 100 ms of data so the speed stays smooth.
  • Each destination file is given its final size (set_len) before the first write. This is best effort and ignored where the file system refuses it; if the source ends up shorter than measured, the files are cut back.
  • Files are copied strictly one after the other by a single thread. Windows' write cache may still flush the previous file to disk while the next one is being read.
  • The graph keeps the whole history of the copy; when it grows too long, neighbouring samples are merged.
  • If two source files share the same name, the later one overwrites the earlier one in the destinations. Existing files in the destinations are overwritten without asking.
  • Dependencies are kept to a minimum: native-windows-gui and windows-sys at run time, embed-resource at build time.

Limitations

  • Windows only.
  • Dropped folders are ignored (no recursive copy yet).
  • The speed limit cannot be changed while a copy is running, and is not available from the command line yet.

License

Ycopy is free software, released under the GNU General Public License v3.0.

About

Windows tool to copy files to 2 destinations at once

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages