05-17-2016 11:27 AM
Solved! Go to Solution.
05-17-2016 11:32 AM
I don't have any examples. But if you look in the File I/O palette, particular the Advanced File Functions palette below that, you'll find everything you need.
05-17-2016 02:27 PM
05-17-2016 02:53 PM
I made a vi that tries to copy a directory and replace it, but it doesn't do a thing. what I am trying to do is copy the directory and replace another directory with the first one, everytime a new file arrives into the source folder. I will leave my vi as an attachment.
Can someone please help me?
Thanks in advance!
05-17-2016 03:08 PM
Can you provide more detail into exactly what you are trying to do?
You have a VI that runs forever because of the false wire to the Stop if True conditional terminal. I really doubt you want your VI in an endless loop.
Your source files and destination file paths need to be set before you run your VI since they are only read at the beginning.
In case 0, you use recursive file list, which is a good idea for grabbing a list of files in a folder. You pass that list of files onto a For Loop. In th For Loop, you have an odd construct of comparing the iteration terminal to the number 1. If True, you pass out a true to stop the For Loop. If False, you pass out a False constant. (Why the case structure? Just eliminate it and pass the boolean value to the stop terminal. but now you have something that will only run one or two times. Passing out the only file in the list, or the 2nd file in the list. Is that what you want?
Then it goes to case 1 and copies the source file path to the destination file path. Are they both folders? It should be since you send a folder to the List Files Recursive. That seems like it is doing what you are asking for. Is it working?
Then it goes to case 2 and deletes that file you got form case 0. What is the point of that?
Then it repeats all over again going back to case 0 and since you have a False wired to the overall while loop.
Is that what you want? It seems odd to me to get a file, copy an entire folder, then delete a file.
05-17-2016 03:10 PM - edited 05-17-2016 03:10 PM
This will copy and replace the files directly in a folder. You can use another FOR loop to handle the directories.
05-17-2016 03:17 PM
Sorry f I didn't provide enough information. I am going to be updating the files in 2 different folders. I want the destination folder to have every file that is updated in the source folder, I want to delete every file in the source folder, but I don't want to lose the folder structure. That is why I want to copy and replace the entire folder and delete the file in the source folder. And I do want this to run forever, always checking if a new file exists.
Please help me out.
05-17-2016 03:22 PM
Then why don't you use the Move File command?
What is putting files in the the first directory? How frequently is it doing it? Is there a risk that you start trying to move out a file from the first directory while it is still being written into that directory? Do you want to instantly start checking that directory for new files and have it keep checking for new files as quick as the PC will allow?
05-17-2016 03:41 PM
05-17-2016 03:52 PM
I figured it out. I just have to use a match pattern and change everything before a particular string and the concatenate the after match with that string and the folder destination.