11-12-2022 01:49 AM - edited 11-12-2022 01:50 AM
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.
Solved! Go to Solution.
11-12-2022 03:52 AM
11-12-2022 05:21 AM
@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.
11-12-2022 09:22 AM - edited 11-12-2022 09:24 AM
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.
11-12-2022 09:44 AM
@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. 😄
11-12-2022 03:03 PM
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
11-12-2022 03:35 PM - edited 11-12-2022 03:44 PM
@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.
11-12-2022 05:47 PM
@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 altenbach
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?
11-13-2022 02:00 PM
I created the code below, but is there an easy way to apply the data size unit conversion?
11-13-2022 05:12 PM