LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Show processing time when trying to copy folders with Labview

Solved!
Go to solution

First of all, hello everyone.


First of all, I want to explain the application I want to create.
1-I want to copy a folder from the PC to a flash disk inserted in the PC.
2-An indicator showing the estimated time the process will take during the copy.

However, in my research and in all the forum posts I've looked at, I haven't been able to find a way to show the processing time for folder copying. I was only able to find this example for file copying.
But the example only tells me to choose a path for one file and each time the VI is run. This is not necessary as I will only copy data between certain paths.

 

I've created an example below to copy the folder but I can't do exactly what I want. I can't calculate the transfer rate because the loop is occupied while copying the folder, while the loop continues to work normally after the copying process is finished.

 

Anyone have an idea for a solution to this problem? I would be grateful for the help..

 

I am using labview 2018-32 bit.

 

0 Kudos
Message 1 of 19
(2,125 Views)

One way is to use Windows own file copy function and show the UI:

thols_0-1668246725906.png

 

Certified LabVIEW Architect
0 Kudos
Message 2 of 19
(2,095 Views)

 


@thols wrote:

One way is to use Windows own file copy function and show the UI:

 

 


Thanks for your answer. That's good. But can I specify the location to open this window?

--Is there an alternative way that can be used directly in labview.

0 Kudos
Message 3 of 19
(2,083 Views)

Even the windows copy dialog is just a guess and often gets it wrong.

 

What is the folder structure? For example if there a a large number of similar folders (e.g. test results), each with a similar number of files of similar size and no subfolders, you could iterate over the folders in a FOR loop and copy each. You know how many there are, and after one copy you also know the time it took for one. With some math, you can get a better and better estimate on the time left to do the rest.

 

0 Kudos
Message 4 of 19
(2,052 Views)
Solution
Accepted by topic author DavidHammer

@altenbach wrote:

What is the folder structure? For example if there a a large number of similar folders (e.g. test results), each with a similar number of files of similar size and no subfolders, you could iterate over the folders in a FOR loop and copy each. You know how many there are, and after one copy you also know the time it took for one. With some math, you can get a better and better estimate on the time left to do the rest.

 


Here's a quick draft. Probably needs some tweaks, nothing a +1 or -1 in the right place cannot fix. 😄

 

altenbach_0-1668267808662.png

 

0 Kudos
Message 5 of 19
(2,042 Views)

If you have large files and want to know progress of copy, copying blocks of binary data is one option:

https://forums.ni.com/t5/Example-Code/File-Transfer-with-Progress-Bar-Using-LabVIEW/ta-p/3507951

 

Certified LabVIEW Architect
0 Kudos
Message 6 of 19
(2,026 Views)

@DavidHammer wrote:

I've created an example below to copy the folder but I can't do exactly what I want. I can't calculate the transfer rate because the loop is occupied while copying the folder, while the loop continues to work normally after the copying process is finished.

 


As an additional comment, you need to understand dataflow, because there are so many things wrong with your code.

 

Of course the loop cannot complete the current iteration until everything in it has completed. In this case the slowest part is the copy process. Before the "Button" (I could probably come up with a slight better button name to start the copy process!) has been pressed (or after the copy process has completed), the loop spins as fast as the computer allows (greedy loop!) burning through 100% of one CPU core, heating your room, and possibly draining your battery. If you would press the button a second time, it would again copy the same hierarchy. That would only make sense if the bulk of the folder contents have changed by an external process. Is that assumption reasonable? If not, why is there even a while loop? Why is the progress indicator I64 if the data is I32? The label "x*2^n 3" is a weird name for a size indicator. The loop time is in ms (milliseconds, i.e. a time unit) in your code, not m/s (meters per second, i.e. a speed unit). Since you don't correctly initialize the shift register, the first displayed value will be garbage. Here's a better way to display the loop time.

 

 

0 Kudos
Message 7 of 19
(2,015 Views)

 


@altenbach wrote:


As an additional comment, you need to understand dataflow, because there are so many things wrong with your code.

 

Of course the loop cannot complete the current iteration until everything in it has completed. In this case the slowest part is the copy process. Before the "Button" (I could probably come up with a slight better button name to start the copy process!) has been pressed (or after the copy process has completed), the loop spins as fast as the computer allows (greedy loop!) burning through 100% of one CPU core, heating your room, and possibly draining your battery. If you would press the button a second time, it would again copy the same hierarchy. That would only make sense if the bulk of the folder contents have changed by an external process. Is that assumption reasonable? If not, why is there even a while loop? Why is the progress indicator I64 if the data is I32? The label "x*2^n 3" is a weird name for a size indicator. The loop time is in ms (milliseconds, i.e. a time unit) in your code, not m/s (meters per second, i.e. a speed unit). Since you don't correctly initialize the shift register, the first displayed value will be garbage. Here's a better way to display the loop time.

 

 


-Yes, when I test and modify too much code, leftovers are scattered around. Wrong indicator names etc.. so sorry.

-There is no point in copying if there are files with the same name for the copy operation. I guess I'll have to fix this.
Another reason I put this in a while loop is because it has to do this every time the button is pressed. (If new USB flash drive is constantly inserted without VI shutdown, it will transfer the same copies to the new USB flash drive)

 

---------------------------------------------------------------------------------------------------------------------

Thank you for your answers. Especially for  

 

I can say that the code here really shed light on my mind.I made a plugin for it like below.

I'm getting results close to exactly what I want.

 

-Nested folders cannot be copied. For this, I may have to change it again.

-In another, how can I show the measurement in bytes as Bytes, KB, MB, GB, TB units automatically when measuring the folder size.
Is there an easy way to do this or should I create a condition for each unit?

 

0 Kudos
Message 8 of 19
(1,993 Views)

I created the code below, but is there an easy way to apply the data size unit conversion?

0 Kudos
Message 9 of 19
(1,919 Views)
  • You still have that greedy while loop!
  • You need to initialize your shift register with zero, else it will continue with the last value from the previous run.
  • You already know how to get the size of a folder (code on the left!), so why are you using file size, which does not work on folders.
  • You need to swap the inputs to the subtraction (Sorry, my mistake) to get rid of all these negate nodes.
  • You don't need that property node. These properties don't change unless you change them manually. You also don't need the "value" if you configure the VI to clear indicators when run.
  • Instead of the "clear error", just wire the error to a structure boundary to suppress automatic error handling.
0 Kudos
Message 10 of 19
(1,896 Views)