(cross-posted as Issue #126562 · python/cpython)
Proposal
py -m shutil copy2 ~/my/src.txt .
I often find it necessary to use some shutil
functionalities in scripts. It does the right thing efficiently, has more precise error handling than cmake -E
, and, most importantly, is cross-platform.
Precedent
The zipfile
module can be used by py -m zipfile
. It gains credits for being a cross-platform ZIP64 decompressor.
Details
- The subcommands should cover
copyfile
,copystat
,copy
,copy2
,copytree
,rmtree
,move
,chown
,which
,make_archive
, andunpack_archive
; - The keyword parameters that expect cross-platform arguments and are easy to represent in cmdline should be adapted into
--kw arg
cmdline options; flags can follow the style--follow_symlinks
and--no-follow_symlinks
(follow_symlinks
doesn’t have a cross-platform behavior, yet, but the arguments are boolean). - It would be even nicer if combined with a progress bar (See also: Add a basic progressbar implementation to
shutil
).