Jump to content

Display A Progress Bar During File Copying...


Recommended Posts

Hello,

I've written a script to copy data DVDs to a hard drive (into certain folders depending on the label, etc) but I would appreciate your help with displaying and updating a progress bar to show progress while copying the files. Here is some code I wrote to attempt to do this:

;Turn progress bar on.

ProgressOn("Working...", "Copying Files...", "0 percent", -1, -1, 19)

;Get the current size of the target DVD in MB.

_RunDOS("Dir /s /-c d:\ > dir.txt")

$dir=FileOpen ("dir.txt", 0)

$bytes=FileReadLine($dir, _FileCountLines("dir.txt") - 1)

FileClose($dir)

$folderSize=StringStripWS(StringTrimRight(StringRight($bytes,18),5),8)

$folderSize=Round($folderSize / 1048576)

$per=Round($folderSize / $size * 100)

;Enable Adlib to update the progress bar while copying files.

AdlibEnable("progBar")

;Start copying files using 'xcopy' to copy only the files that don't exist on target.

_RunDos("Xcopy /y /f /d /s /e D:\ " & $target) ;The target folder will vary.

Func progBar()

$freeNow=Round(DriveSpaceFree("C:"))

$growth=Round($free - $freeNow)

$folderSize=$folderSize + $growth

$per=Round($folderSize / $size * 100)

$foldersize=$folderSize - $growth

If $per > 0 Then ProgressSet($per, $per & " percent")

EndFunc

The above code does work to at least some extent but I'd like any suggestions or better ways to do the same thing.

Thank you very much.

Kendall

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...