Jump to content

Progress bar showing file copy


sjorrel
 Share

Recommended Posts

Hi,

The script I am creating copies a large file accross a network (about 500Mb).

It works, but there isn't much feedback showing what is going on - it just waits until the file is copied and moves on.

Is there a way of creating a progress bar that will show the file being copied?

I realise I could just create a window that appears and says 'file being copied' and then is deleted when it is finished, but it would be useful to have an accurate display of the progress of the file copy process.

Thanks in advance fo any help.

Link to comment
Share on other sites

You could do an AdLib with FileGetSize

Going to bed, reply if you need me to elaborate in the morning :)

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

You could do an AdLib with FileGetSize

I think i know what you mean:

Start the file copy, then have a loop that gets the file size of the file on the local disk as it is copied, get the file size of the source file, work out the percentage copied and then update the progress bar.

Which is what I thought of, but how could I get the loop to update the progress bar to start whilst the script is waiting on the file to finish copying? (which is what it seems to do at the moment).

Link to comment
Share on other sites

Oops I just got your full meaning - an AdLib function seems to work in the background in the way i wanted.

Will try it now - thanks!

Update:

Tried playing about with the adlib function. i can't get it to work when a filecopy is happening - i've looked around the forums and it seems that adlib functions are disabled during certain events (such as when a msgbox is displayed) - do adlib functions definately work when a filecopy is occuring?

Edited by sjorrel
Link to comment
Share on other sites

well if they don't you can always run 2 scripts at once

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

you probably want to compile the second script then run it like this

Run ( 'script.exe "command line 1" "command line 2" "command line 3"' )
I think most of it is in the help guide

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

Thanks for the help

I've worked out passing command line arguments.

However i still have a problem.

Say I have my main script, and an additional script to do something else.

If i compile the 'subscript' I can give it command line arguments, and I'll do this from the main script using the 'run' command - but doing this will give me two executables rather than just one.

If use the 'include' function, I'll be able to compile them both as one file - but I can't find a way of passing command line options to an included script.

Is there a way? Or am I going about this the wrong way?

Edited by sjorrel
Link to comment
Share on other sites

you cannot include a compiled script you have to do FileInstall then use the run command

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

Thanks for the help guys.

I tried it before Larry's post and got it to work by including using fileinstall and passing arguments with the run command. And it seems to work.

Unfortunately as soon as the file copy starts the size of the file is reported as being the same size as the source file - I assume this is just the behaviour of windows for any file copy. At any stage in the copy, using the dos 'dir' command shows the size the file will eventually be. Because of this, the progress bar immediately shoots up to 100% and stays there until the file has copied.

:)

Link to comment
Share on other sites

This works with the "COM" version of Autoit ...

$src = "d:\myfile\here\driver.cab" 
$dst = "c:\"

$oSh = ObjCreate("Shell.Application")
$oFld = $oSh.NameSpace($dst)
$oFld.CopyHere($src)
$oSh = 0
$oFld = 0

Edit: Hey!!! It copies directory structure too ...

$src = "d:\myfile\here\*.*" 
$dst = "c:\Back-Up\"

$oSh = ObjCreate("Shell.Application")
$oFld = $oSh.NameSpace($dst)
$oFld.CopyHere($src)
$oSh = 0
$oFld = 0

copies all files and folders in the source directory and puts them into the destination directory ... AND shows the windows file copying progressbar

Edited by sykes

We have enough youth. How about a fountain of SMART?

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...