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: 

How to copy and rename a tdms file?

Hi all,
I need to copy and rename a tdms file in Labview.
 
I've tried the following:
1) Read the whole tdms file as a string (with vi "Read from Text File")
2) Search and replace the "...tdms" names from the source file (with "Search and Replace String")
3) Write the replaced string into the new TDMS file with vi "Write to Text File"
 
But the problem in this procedure is that there are some line breaks in the new tdms file and so the tdms file is incorrect 😞
 
Has anybody an idea how I can copy and rename an tdms file?
 
Best regards
daHans
0 Kudos
Message 1 of 7
(6,253 Views)
Hello,

I think that what you want it's a simple file rename, no?

See the attached picture...
Software developer
www.mcm-electronics.com





PORTUGAL
Message 2 of 7
(6,250 Views)
Hi,
the problem is that it's not a simple file rename because I have to replace some strings in the file contents which reference to the file name 😞
 
Best regards
daHans
0 Kudos
Message 3 of 7
(6,240 Views)
ok,

But why don't you post an example file so that I can see better the problem?
Software developer
www.mcm-electronics.com





PORTUGAL
Message 4 of 7
(6,240 Views)

Hi,

I haven't posted an example file because it's a general question "how can tdms files copied and renamed?

But thanks for your answers 🙂

daHans

0 Kudos
Message 5 of 7
(6,224 Views)
Short answer
You can copy and rename TDMS files using either LabVIEW functions, Windows Explorer or whatever tool you prefer. You can either copy / rename the TDMS and the TDMS_INDEX file, or just the TDMS file. If you have saved any properties / values that you need to adapt to the new file name, use the TDM Streaming functions do modify them as needed.

Details

TDMS files do not have any "built-in" references to the TDMS_INDEX file. You can even delete the TDMS_INDEX file and we will regenerate it the next time you access the file. If you have the NI DataFinder running, the index file will be "magically" recreated by the DataFinder background process. The information contained in the TDMS_INDEX file is redundant to parts of the TDMS file, the index file just speeds up reading quite a bit.

This is a big difference between TDMS and TDM files. If you want to rename a TDM file, you will have to replace an internal string that points to the binary part of the TDM file. You might be able to find the details on that in some other developer zone thread, I answered it there a couple of weeks ago.

Processing a TDMS file as a string is generally a bad idea because it is a binary file and string processing will convert it to an alphanumeric character set and thereby corrupt the file.

Herbert
Message 6 of 7
(6,223 Views)

Hi Herbert,

thanks for your great answer!!

🙂

daHans

0 Kudos
Message 7 of 7
(6,202 Views)