I suppose I could compare the number of files in the source directory to the number of files in the target directory as cp progresses, or perhaps do it with folder size instead? I tried to find examples, but all bash progress bars seem to be written for copying single files. I want to copy a bunch of files (or a directory, if the former is not possible).
While it doesn't display speed, when copying multiple files, the -v option to the cp command will provide you with progress info.
pv Command You can use the “pv” command for copying a single file as it provides statistics related to the progress and speed. In the following case, “pv” will output the “inputfile” to “stdout”, which is then redirected to the “outputfile” using the “>”operator.
In order to copy a directory on Linux, you have to execute the “cp” command with the “-R” option for recursive and specify the source and destination directories to be copied.
Copying Directories with cp Command To copy a directory, including all its files and subdirectories, use the -R or -r option.
You can also use rsync
instead of cp
like this:
rsync -Pa source destination
Which will give you a progress bar and estimated time of completion. Very handy.
To show a progress bar while doing a recursive copy of files & folders & subfolders (including links and file attributes), you can use gcp
(easily installed in Ubuntu and Debian by running "sudo apt-get install gcp"):
gcp -rf SRC DEST
Here is the typical output while copying a large folder of files:
Copying 1.33 GiB 73% |##################### | 230.19 M/s ETA: 00:00:07
Notice that it shows just one progress bar for the whole operation, whereas if you want a single progress bar per file, you can use rsync
:
rsync -ah --progress SRC DEST
You may have a look at the tool vcp
. Thats a simple copy tool with two progress bars: One for the current file, and one for overall.
EDIT
Here is the link to the sources: http://members.iinet.net.au/~lynx/vcp/ Manpage can be found here: http://linux.die.net/man/1/vcp
Most distributions have a package for it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With