Windows

How to add a file copy progress indicator to scripts

One of the frustrating things with scripting and copying files is knowing where in the file copy your copy actually is.  Especially if you are copying a very large file that is several gigs, you can definitely benefit from knowing how much of the copy is left to go.  If you are used to using the DOS copy command, you know there is no switch with this command that allows you to see the file copy status, also XCOPY is lacking in this area as well.

We have covered a few of the benefits of using the robocopy command in previous posts, but one of the slick features of robocopy is that you CAN see the progress of a file copy in your scripts by utilizing this file copy utility. This again is extremely helpful in copying large files and seeing the progression of the job so that you can gauge other tasks that need to be accomplished.

Let’s take a look at the syntax of copying a file and seeing the progress indicator.  The syntax for copying a single file is a little bit different from what we are used to using in other copy commands:

  • robocopy z: n: someimage.wim /V /TEE

robofeat

As you can see in the command above you tell robocopy the source drive first, then the destination drive, THEN the file you want to copy.  The /V /TEE switches add the functionality of the command that we need to be able to see the progress percentage indicator that will help us see where we are in the copy process.

As you can see in the example above, this is extremely helpful to have this output when you are copying for instance a .wim image that is extremely large and you may be imaging several computers and need to see the progress of the copy.

This is easily added to the .wim image batch file that we described in the post here about End to End Wim Image deployment with WDS.

Final Thoughts

Robocopy is a great utility that every system administrator should be familiar with that allows you to do things that other copy utilities just simply cannot do.  The progress indicator builtin to this utility is extremely helpful in large copy jobs or in image copies where knowing the progress may be crucial and at the very least helpful.

Back to top button