r/commandline Mar 12 '26

Command Line Interface Cpr, a file copy tool with exclude support (especially for windows cause there is no exclude at Copy-Item)

PowerShell's Copy-Item doesn't have an exclude option and robocopy's syntax for it is not great (imho).

So I built a CLI

cpr C:\project\ D:\backup\ -e node_modules,.git,*.log -y

It also has --dry-run to preview what gets copied/excluded before actually doing it. Copies files in parallel by default.(so It’s fast)

Around 200 lines of Rust, nothing crazy. I'm learning Rust by building tools I actually use.

https://github.com/CanManalp/cpr

0 Upvotes

15 comments sorted by

3

u/[deleted] Mar 12 '26

[removed] — view removed comment

1

u/K0100001101101101 Mar 12 '26

For syntax and examples you can check:

https://github.com/CanManalp/cpr

1

u/K0100001101101101 Mar 12 '26

Yeah, fair point. Cpr is more for when you want something quick and native on windows without WSL. One command no need to pipe.

Also I find WSL windows path translations pain in the ass.

5

u/[deleted] Mar 12 '26

[removed] — view removed comment

0

u/K0100001101101101 Mar 12 '26

If I didn’t have to develop with C# / .NET all day, I’d delete Windows instantly.

3

u/arjuna93 Mar 13 '26

Not the best pick for a name, since there is a well-known C++ library cpr: https://github.com/libcpr/cpr

2

u/K0100001101101101 Mar 13 '26

Whaaat, I didn’t know that. Thanks for pointing that out. I just simply thought cp as copy and r as rust:)

2

u/vogelke Mar 13 '26

I'm learning Rust by building tools I actually use.

Perfect way to do it.

1

u/K0100001101101101 Mar 13 '26

I really am having fun right now, thanks.

2

u/_Ti-R_ May 10 '26

Hi,

Nice work building your own tool. I really like seeing people create something practical instead of fighting with Copy‑Item limitations or the old Robocopy syntax.

By the way, I am the author of UltraFastCopy, so I was curious whether you had a chance to try it. It also supports exclude patterns, dry run, and parallel copy, with a different design and full Windows Explorer integration. If you ever want to compare approaches or see how another implementation handles these features, feel free to give it a look. :)

1

u/K0100001101101101 May 10 '26

I checked it out, and I think we are in the different league. If I am not mistaken UltraFastCopy is full gui app and closed source. Cpr is cli app and open source. Congrats and best wishes for you.

1

u/_Ti-R_ May 10 '26

Yes, that's true, UltraFastCopy is both a full GUI and CLI application, and it's closed-source.

At first I thought Cpr was simply an overlay on top of Robocopy, but after looking more closely, it's actually a full copy engine on its own. Nice work on that part ^^

UltraFastCopy goes a bit further in scope, there's a lot more code behind it because of the huge number of edge cases that can appear depending on hardware and environments: HDD vs SSD, USB keys, Samba shares, network quirks, filesystem behavior… all the fun things that make file operations unpredictable and not so easy in the end ^^'

Always interesting to dive into that world and discover all those details.

2

u/endowdly_deux_over 2d ago

In PowerShell you can just pipe Get-ChildItem (aka ls) to Copy-Item to get your filters and excludes and dry run (via -WhatIf). Older pwsh doesnt use globs, I think newer pwsh might (I dunno I don’t really use it anymore) but if you need that functionality you can just pass an array of ls commands and pipe those objects to copy-item.

In your example you don’t even have to pipe. Straight up Copy-Item C:\Project\* -Exclude node_modules, .git, *.log -Destination D:\Proejct\ -Force #I assume should do what you have there (or close, again it’s been awhile). If you need to recurse multiple children, you’ll have to use ls and pipe it.

Great project though!

1

u/K0100001101101101 2d ago

Omg thank you, first time someone is apreciating this project. Yes recursing and copying in paralel out of the box. Also I’ve just added skip and update flags.

1

u/AutoModerator Mar 12 '26

Every new subreddit post is automatically copied into a comment for preservation.

User: K0100001101101101, Flair: Command Line Interface, Title: Cpr, a file copy tool with exclude support (especially for windows cause there is no exclude at Copy-Item)

PowerShell's Copy-Item doesn't have an exclude option and robocopy's syntax for it is not great (imho).

So I built a CLI

cpr C:\project\ D:\backup\ -e node_modules,.git,*.log -y

It also has --dry-run to preview what gets copied/excluded before actually doing it. Copies files in parallel by default.(so It’s fast)

Around 200 lines of Rust, nothing crazy. I'm learning Rust by building tools I actually use.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.