ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

changing extensions

Hi,

 

I would like to change the extensions of some files with Labview is that possible? It's like 30 filenames in one map, which I want to do in a loop, but the filenames change every month so I need some kind of code that runs through every file in that map in the order they are present.

 

Tx in advance

0 Kudos
Message 1 of 9
(5,812 Views)

Hi KF,

 

yes it's possible to change filenames...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(5,801 Views)

As GerdW suggests, you can move and rename. You can also copy to a new name.

In the attached (V8.5) I grab all of the files in a directory and using an autoindexed loop create new versions with new extensions. If you don't want the old versions either delete them or use Move as GerdW mentions.

 

extensions.PNG

Message 3 of 9
(5,793 Views)

You can also change the extension using regular expressions:

 

 

NOTE: Obviously, the paths as strings would come from a Path to String function. Remember: Don't create paths using strings.

Message 4 of 9
(5,782 Views)

 


@smercurio_fc wrote:

You can also change the extension using regular expressions:

 


 

Neat (but messing with my head slightly)

In my continuing efforts to understand regex... I think this is doing the following:

 

\ .  means look for the dot before the file extension then,

([^.\\]+) means start at the beginning of the extenstion (^) look for anything followed by a back slash (.\\) and do this search as many times as possible (+)

$ means match from the end of the string (i.e. after the dot used to indicate the file extension rather than before it)

 

I think I'm missing something in that middle step - what is the backslash for? Please could someone enlighten me?

 

Thanks

Ian

0 Kudos
Message 5 of 9
(5,764 Views)

great stuff guys, gonna try it out thanks

0 Kudos
Message 6 of 9
(5,751 Views)

The middle part basically matches the pieces of text that are not a period or a backslash. Of this set the rest picks out the last one (which should be the extension). RegExr is a good site to analyzer regular expressions.

Message 7 of 9
(5,748 Views)

Hi,

 

I have one more problem to start the rest of the code, I used your suggestions and created .lvm files with several columns of numbers, the first column is date and hour though. I need the first 3 columns of numbers (not the dates and hours) to work with, so i need arrays of those. I can't really find how to do that. I attached an example of a .lvm file.

 

thanks

0 Kudos
Message 8 of 9
(5,724 Views)

Never mind I found it, use read spreadsheet with ; as delimiter

0 Kudos
Message 9 of 9
(5,709 Views)