09-02-2009 12:53 PM
I needed a program that would take in a pathname, see if the file name already existed at that location, and if so it needed to auto-increment the file name. I wanted it to work the way windows inherently does when you copy a file of the same name into a location because that seems the most natural to me. I was running into problems with the ftp functions in the internet toolkit becaues if the local file already exists at the path you input, it just doesn't perform the get files function.
I discovered after searching the forums that a lot of people run into this all the time and usually the way they get a unique file name is by adding the date and time to the end of the file. This is both effective and informative, but results in unnecessarily long and ugly file names.
So I made a subVI and I wanted to share it with you guys. Hope someone finds it useful. Let me know what you think.
09-02-2009 01:15 PM
Thank you for sharing this VI. You should consider upload previous versions of the VI so that users who don't have LV 2009 can look at the code as well.
09-02-2009 01:21 PM
Nice VI (good icon!).
Two minor points:
09-02-2009 01:37 PM
I took your suggestions
- appended (T) to the check existence input description to indicate its default position
- Created a "New Path?" output that idicates whether a new path was created (T) or if the inputted path was simply passed through (F)
And for all the users who dont have 2009... Here are some older versions for you 🙂
enjoy
09-02-2009 02:05 PM
I'll add a related example to this thread. This old-dog has been around for a while, I spent a few minutes cleaning it up, but it by no means is as ready for prime time as yours. (I'll probably pilfer that icon). I use this one a lot, it lets me enter a base filename and a path and it returns the list of files with the matching pattern, pulls the number from the last one and increments. If the path is empty you get a dialog so I usually put the path out into a shift register. First time I run I am asked where to put the files and then I can collect data one file at a time. Hard-wired for 4 digits, zero-padding is very important for keeping the files in alphabetical as well as chronological order.
09-02-2009 02:30 PM
Your example definately pointed out a case where previous versions of my VI could output a non-unique filename.
If there were two files, file.txt and file(1).txt in a directory and you inputted "file.txt" into my VI it would output "file(1).txt" which would be a non-unique filename.
Fixed version coming shortly.
I am still deciding whether or not to add functionality that will allow me to input the number of digits of the number to use for increment (zero padding).
09-02-2009 02:38 PM
Well it was an easy fix so here it is (without zero padding)
Version 1.3 🙂
09-03-2009 10:50 AM
Hi all,
Don't forget that when you create awesome VIs that you want to share with the community, you should upload them on the NI Community. If you've got 2009, don't forget to use the new VI Snippet feature to post pictures of your code! Thanks for your great work!
09-03-2009 11:56 AM
09-03-2009 12:03 PM