LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Renaming an existing text file

This should be a rather simple problem for a lot of you more experienced programmers. I'm trying to do 10 things at once right now and this text file issue is thing number 11, so I thought I'd save me some time and let you guys suggest a clean way to do this!

My program allows the operator to enter in a serial number for the device they will test. This serial number is used as the name of the text file that stores the test cycle data for that unit. What I would like my program to do is to first check and see if there is already a text file with that name that already exists. I have that part working.

Next, if it finds a file with that name already, I would like LabView to automatically rename the existing file (I'm renaming it by concatenating the current date/time string on to the file name), then move that renamed file to a different folder called "Backup files".

Like I said, this is a fairly simple task and I'm running into some stupid hiccups. So I would greatly appreciate some tips on this from you all while I focus on some other program issues for now.

Thanks!
********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 1 of 8
(6,899 Views)
The Move function (File I/O>>Advandec File Function) allows to move and rename a file. In the target path input, select the new location and file name. The target folder must exist since it is not created automatically (Use New Directory as required). To rename a file a file in the same foleder, use Move function and just change the file name in the target path.


LabVIEW, C'est LabVIEW

0 Kudos
Message 2 of 8
(6,895 Views)
Okay, I followed your suggestion and I'm still getting a hiccup. I'll enclose a copy of the code I'm using so you can see what I'm doing wrong hopefully.

The error I'm getting is from the MOVE command and LV is telling me:




Error 1 occurred at Move in HVAC Serial communication testF.vi

Possible reason(s):

LabVIEW: An input parameter is invalid.
---
NI-488: Command requires GPIB Controller to be Controller in Charge.
********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 3 of 8
(6,889 Views)
I'm still tinkering and getting close, but not quite there.

The biggest problem I'm running into is when I do the MOVE command. In the "source path" I put in the name of the folder and the file that I want to rename and move. In my target path, I'm putting in the new folder and new file name for that file.

For example my source path in my test code is "C:\LabView data\EMD sub-base\123.txt" and the target path I'm putting in is "C:\LabView data\Backup\123-(whatever the current date and time is).txt."

This is the error code I'm getting now:

LabVIEW: Duplicate path.
---
NI-488: New I/O attempted with old I/O in progress.
********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 4 of 8
(6,881 Views)
Hi there,

There are two reasons why you're getting errors:
1)A file name cannot contain \/:*?<>"| which is the case (\ and 🙂 for the target filename in your VI
2)Since you're doing a MOVE and not a COPY operation, you're trying to delete a file which, in case of a successful move, is not there anymore. Since the file is moved and not copied the delete is unnecessary

Find attached a VI that should solve your problems,

regards
Cyril Bouton
Active LabVIEW Developper
Message 5 of 8
(6,867 Views)
Hi Cyril,
 you can seand this example  for labview 7.0 or as jpg sow i can see that. i have labview 7.0 and i cant open your example.
thank's.
eyal.
0 Kudos
Message 6 of 8
(6,778 Views)

eyal,

Here is Cyril's program saved for 7.0. Have a good one!

 

0 Kudos
Message 7 of 8
(6,758 Views)
thank you verey much!!!Smiley Very Happy
0 Kudos
Message 8 of 8
(6,737 Views)