Add a progress bar to PST copy batch file

2.4k Views Asked by At

I have a basis of a copy script (using xcopy) to copy over files for migrating over from one pc to another (xp to win7 in my case).

Here is the code: ...

xcopy /I /Y /E /F "C:\Documents and Settings\%USERNAME%\Favorites\*.*" h:\Restore\IE favorites
xcopy /I /Y /S /F "C:\Documents and Settings\%USERNAME%\Desktop" h:\restore\desktop
xcopy /I /Y /F "C:\Documents and Settings\%USERNAME%\Application Data\Microsoft\Outlook\*.nk2" h:\restore\Outlook-NK2
xcopy /I /Y /F "C:\Documents and Settings\%USERNAME%\Application Data\Microsoft\Signatures" h:\restore\Signatures
xcopy /I /Y /F "C:\Documents and Settings\%USERNAME%\Application Data\Microsoft\Office\*.acl" h:\restore\Office-AutoCorrectLists
xcopy /I /Y /F "C:\Documents and Settings\%USERNAME%\Local Settings\Application Data\Microsoft\Outlook\*.pst" h:\restore\PST1
xcopy /I /Y /F "C:\Documents and Settings\%USERNAME%\Application Data\Microsoft\Outlook\*.pst" h:\restore\PST2

xcopy /I /Y /F "C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Outlook" h:\restore\Roaming\Outlook
xcopy /I /Y /F "C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Signatures" h:\restore\Roaming\Signatures

regedit /s /e H:\restore\HKCU-RestoreODBC.reg "HKEY_CURRENT_USER\Software\ODBC\ODBC.INI"
regedit /s /e H:\restore\HKLM-RestoreODBC.reg "HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI"

regedit /s /e H:\restore\restornetwork.reg "HKEY_CURRENT_USER\Network"
regedit /s /e H:\restore\HKLM-RestoreIECert_machine.reg "HKEY_LOCAL_MACHINE\Software\Microsoft\SystemCertificates"
regedit /s /e H:\restore\HKCU-RestoreIECert_machine.reg "HKEY_CURRENT_USER\Software\Microsoft\SystemCertificates"
regedit /s /e H:\restore\RestorePrinterConnections.reg "HKEY_CURRENT_USER\Printers\Connections

I'd like to add a progress bar to the copying of the PST portion of the code, but I don;t know where to start with this. Would anyone mind helping me out with a few tips on how I could start with this?

Thanks very much.

2

There are 2 best solutions below

0
On

Use ROBOCOPY instead of XCOPY. See ROBOCOPY /?

2
On

If you can't use robocopy as RGuggisberg suggested, there's the old dot notation:

echo.|set /p=.

Each time you call it, it will put down one dot. For example, you could call it as follows:

:: hide xcopy output with > nul so dot ticker output will be visible
xcopy ... > nul
call :percentage
regedit ... > nul
call :percentage
goto :EOF

:percentage
echo.|set /p=.
goto :EOF

It can be called after any operation also.