SmartFAQ is developed by The SmartFactory (http://www.smartfactory.ca), a division of InBox Solutions (http://www.inboxsolutions.net)
How To Show a Progress Bar While Copying Files?
Requested by Anonymous and Answered by Frank-Peter Schultze [webmaster] on 15-Sep-2005 01:51 (30143 reads)
"Basically, I am writing a batch program that copies 2 files to a backup folder named (current date). I want to improve this to also show dots to show some kind of activity while copying. I am thinking of using a loop but what would be my ending parameter (otherwise, it becomes an infinite loop). Do you have a better solution to this? Thanks in advance!"
The approach below executes the copy command in an additional (minimized) command window and then creates a flag file. During the file copy the main batch checks every second for the flag file and shows a period if the flag file does not exist.
::Copy the first file.
Call :Pcopy "source 1" target1 /Options
::Copy the second file.
Call :Pcopy source2 "target 2" /Options
If Exist %Flagfile% Del %Flagfile%
Start /Min Copy %* ^& Echo.^>%Flagfile% ^& Exit
(Set /P i=Copying %1) < NUL
If Exist %Flagfile% (Goto :EOF)
::Echo period w/o carriage return/line feed
(Set /P i=.) < NUL
::Wait one second (increase no. of ping requests
::in order to wait for a longer time)
Ping -n 2 127.0.0.1 > NUL
Download a batch file that uses this method.