From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

assign new name to root file using root properties

Hello There, 

I ve, 

Current File name = Test1.tdms

which has Properties such as :

     1. Lab = 123

     2. Load = Heavy

     3. Machine = 5

     4.Method = Fast

     5.Run = 2

 

my required New File name = concatenate of specified root properties spaced with underscore followed by the extension.tdms

i.e 

New File name = concatenate [Data.Root.Properties("Lab"),Data.Root.Properties("Load"),Data.Root.Properties("Machine"),Data.Root.Properties("Method"),Data.Root.Properties("Run")] each property seperated by "_"

 

New File name = 123_Heavy_5_Fast_2.tdms

 

I need to perform this for multiple tdms files.

I ve attached a sample file

Please guide me thru this scripting process

 

 

0 Kudos
Message 1 of 4
(4,771 Views)

Hello rarun,

 
You can use the function DataFileRename:
 
Command: DataFileRename
 
 
This community example may in concatenating the text:
Change File Names in a directory with DIAdem

 

Regards,

 

Samuel S.

Applications Engineer

National Instruments

www.ni.com/support

 

 

0 Kudos
Message 2 of 4
(4,749 Views)

Thanks Sam,

 

This is how I approached it, let me know if you have any better way to do it. (refer attachement Test1.tdms from previous post)

 

dim a,b,c,d,e, newname

 

a=Data.Root.Properties("Lab").Value

b=Data.Root.Properties("Load").Value

c=Data.Root.Properties("Machine").Value

d=Data.Root.Properties("Method").Value

e=Data.Root.Properties("Run").Value

 

newname=a+"_"+b+"_"+c+"_"+d+"_"+e

 

Call DataFileSave(newname,"TDMS")

 

Ques 1 : When I use 'DataFileRename' it provides this error ---- >  Operating system error :"-2"

 

Ques2 : I would like to keep certain length of my current file name and replace the rest with customized name

eg: current name = LR1634240_U4_Double_Loop_12_C_150331_154739.tdms

       newname = newname + _150331_154739.tdms

       The first part of the name is customized based on the above aproach

       The value of second part after '+' is unique to the file but the format of the second part is common for all other files.

 

How to perform this action.

 

Thanks

Arun

 

 

 

 

0 Kudos
Message 3 of 4
(4,722 Views)
Hello Rarun,
 
1. You cannot use the variable "e", this is reserved by VBS
 
2. To concatenate strings, you must use &, not +
 
The following example may help with the second part of your question:
 
Change File Names in a directory with DIAdem
 
Also, here are resources regarding Regular Expressions in Diadem:
 
Regular Expressions

 

Regards,

 

Sam S.

Applications Engineer

National Instruments

www.ni.com/support

(866) 275-6964

 

0 Kudos
Message 4 of 4
(4,698 Views)