WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: jcmn on October 07, 2019, 07:12:47 AM

Title: Progress Bar
Post by: jcmn on October 07, 2019, 07:12:47 AM
Hello

I'm new here with this script language.

I would like that someone could give me an example of a script with a progress bar for a copying files task where the progress bar shows the number of files already copied.

Thanks in advance.
Title: Re: Progress Bar
Post by: jmburton2001 on October 07, 2019, 07:26:12 AM
I'm a hobbyist so I tend to use the easiest solution.

Look into aStatusBar (Creates a simple "progress-indicator / thermometer bar" with title, text, and the progress indicator).

I use it for all my progress bar applications. Some of them with over 150,000 items. In your application it would be easy to show a progress bar with the name of the file being copied, the number of files already copied, and the number of files left to copy (and maybe even a percentage completion).

EDIT: I have some time today if you'd like some more detailed assistance.
Title: Re: Progress Bar
Post by: td on October 07, 2019, 07:52:20 AM
AStatusBar is likely the best approach in terms of appearance and ease of use.  While not strictly speaking a progress bar, the WinBatch Box functions are roll-your-own approach that allows you to provide the viewer with any information you see fit. 
Title: Re: Progress Bar
Post by: jcmn on October 07, 2019, 08:07:33 AM
Thanks

I'll try it.
Title: Re: Progress Bar
Post by: jcmn on October 07, 2019, 08:16:57 AM
Quote from: jmburton2001 on October 07, 2019, 07:26:12 AM
I'm a hobbyist so I tend to use the easiest solution.

Look into aStatusBar (Creates a simple "progress-indicator / thermometer bar" with title, text, and the progress indicator).

I use it for all my progress bar applications. Some of them with over 150,000 items. In your application it would be easy to show a progress bar with the name of the file being copied, the number of files already copied, and the number of files left to copy (and maybe even a percentage completion).

EDIT: I have some time today if you'd like some more detailed assistance.

Didn't find anything in help files about aStatusBar , is it a function? a command? an object?

Could you give an example?
Title: Re: Progress Bar
Post by: jmburton2001 on October 07, 2019, 08:33:40 AM
It's in the "Consolidated WIL Help" file. Do a search for astatusbar and you'll find it in the "Shell Operations Extender" functions. Example 1 would probably be most appropriate for a file copy operation.

In it's most basic form it works like this:

1. Initialize the status bar

2. Do some work and update the status bar during this work

3. When finished with your work, kill it

Title: Re: Progress Bar
Post by: td on October 07, 2019, 09:27:31 AM
You do need to download and install the Shell Operations extender before the function will appear in the Consolidated WIL Help file.
Title: Re: Progress Bar
Post by: jcmn on October 07, 2019, 09:48:25 AM
Quote from: td on October 07, 2019, 09:27:31 AM
You do need to download and install the Shell Operations extender before the function will appear in the Consolidated WIL Help file.

OK Got it.

It has also a progress bar dedicated to copying of files.

I don't see in the copyfiles an optins for overwrite of files like for example copy if newer
Title: Re: Progress Bar
Post by: td on October 07, 2019, 10:04:36 AM
Assuming that you are referring to the aFileCopy functions, its primary purpose is not to be used as a status bar.  Its primary purpose is to provide a way to use the Window shell's file copy functionality which is a bit different than a straight file system copy.  You need to use aStatusBar.
Title: Re: Progress Bar
Post by: jmburton2001 on October 07, 2019, 10:15:13 AM
If you would be more forthcoming with what you're trying to do, we could probably give you more accurate help and maybe even some code snippets.

It's hard to give an example if we don't know what you're trying to accomplish. Until then you'll only receive generic answers.

Just to be sure you're up to date, you should probably download and run vcheck. https://www.winbatch.com/download.html
Title: Re: Progress Bar
Post by: jcmn on October 08, 2019, 01:05:45 AM
Hello again

What I only want at this moment of learning is a code example of the use of the progress bar in a copy operation.

By the way looking at all the options in the extender it seems that in a copy operation there is no option to "overwrite only newer files and skip older ones" when files already exist in the destination.
Is it true?

Meanwhile eventually I will ask for help as needed when new challenges come up on my work. And there is an heavy one in the horizon that I will take here later.

I'm not completely a rookie in this kind of programming, years ago I made  a lot of programming with AUTOIT language that have some similarities with WINBATCH. I decided to try WINBATCH because it has a complete set of tools to help in the programming, like the Dialog Editor.

And to finish this reply I already made a dialog with buttons to run applications and files for a daily use.


Title: Re: Progress Bar
Post by: td on October 08, 2019, 07:34:57 AM
Quote from: jcmn on October 08, 2019, 01:05:45 AM
By the way looking at all the options in the extender it seems that in a copy operation there is no option to "overwrite only newer files and skip older ones" when files already exist in the destination.
Is it true?

No, the extenders aFileCopy function does not have an option to "overwrite only newer files and skip older ones".  You don't need to have the extender perform the file copy. You just need to use the aStatusBar function to display a status bar.  You can use the FileCopy or FileMove functions to perform the actual file movement.  You can also use the FileTimeCode, FileTimeGet, or FileTimeGetEx function to check file times.

There are examples for each function in the help file and more examples in the Tech Database.  It is a fairly straight forward process to stitch these functions together in the way you prefer to perform your task.