LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rename csv file

Solved!
Go to solution

Hi,

 

After an exhausting search of this forum and a lot of trial-and-error, I have not been able to work out how to rename a .csv file.  For example, i want to change the name of the csv files in a folder to include the name of the folder. E.g. From Trial01 to Folder1_Trial01.

 

Can someone help me, please!

 

Thanks

 

CJ

0 Kudos
Message 1 of 11
(3,436 Views)

CJ,

 

what version of LV are you using?

 

In general, this is rather simple:

Open the file with file open, copy it to the new location/name and then delete the original file. If this seems rather overelaborate to you, you have to use Windows SDK commands for this (or use .NET or any other API delivering a dedicated "rename"-function), which will result in more complex code.

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 11
(3,432 Views)

Hi Norbert, 

 

I am using Student version 9.0.1.

 

Thanks, 

 

CJ

0 Kudos
Message 3 of 11
(3,428 Views)

Also, I have used the move file function however, it doesn't like the source path name even though there aren't any characters that should cause a problem i the name.

0 Kudos
Message 4 of 11
(3,426 Views)

CJ,

 

move will not work since it does not accept a filename, only directory information. So you will not be able to rename any file using this function.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 5 of 11
(3,422 Views)

Ok, great. That solves that issue then!

 

Is there another way that I can rename these CSV files rather than manually?  I tried to use 'read spreadsheet' and then 'write spreadsheet' without manipulating the data in the files but the contents of the CSV were different and the file was much, much larger.

 

It seems like a pretty simple thing to do I just can't figure how to do it!  Otherwise, i'm going to have to rename 300+ files!!! Eeek!

 

Thanks again, 

 

CJ

0 Kudos
Message 6 of 11
(3,420 Views)

CJ,

 

you can insert your "rename algorithm" in a loop and then building the filenames dynamically for each iteration.

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 7 of 11
(3,418 Views)

Ok. So far i have been able to build the name i want but not rename the file or even make a duplicate with a different name. Is it possible for you to display an example of what your suggestion might look like?

 

Thanks, 

 

CJ

0 Kudos
Message 8 of 11
(3,414 Views)
Solution
Accepted by topic author Corey J

CJ,

 

you might try something like this:

renamefile.PNG

 

Norbert

 

PS: If this is hard to understand for you, you might want to do some online training or visit a LV course from NI.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 9 of 11
(3,409 Views)

Awesome!  That worked a treat! I was close but had a few build path issues i think.

 

Also, i have done a Basics 1 & 2 course but as you may understand, the course does not cover everything!

 

Thanks again, Norbert.

 

CJ

0 Kudos
Message 10 of 11
(3,404 Views)