DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Append Text To the End of File Name - Before the Extension

Solved!
Go to solution

Hi,

 

I am writing a script to batch process data recorded during experiments. After I input the files through the file selection dialog box, I run a for loop in which in which I carry out the actual processing for the selected files. Before running the next iteration of the loop for the second selected file, I would like to append a suffix to the end of the file and save it. (e.g. if the selected files were "exp1.TDMS" and "exp2.TDMS" I would like it to rename the first file and save it as "Exp1_processed.TDMS" before starting the second iteration of the loop in which "exp2" is processed and saved as "exp2_processed.TDMS").

 

Has anyone got any suggestions on how to do this? I have pasted how my script looks like at the moment (which overwrites the old file). Hope I have been clear and thanks in advance!

 

 

 

if FileDlgShow("C:\Experiments\","TDMS Files,*.tdms","Data to be processed",true)= "IDOk" Then

For iCount = 0 to UBound(FileDlgNameList)
Call DataFileLoadRed (FileDlgNameList(iCount),"TDMS","","IntervalCount",62000,1,0,0)

... data processing ...

Call DataFileSave(DataFileName,"TDMS")

Next

 

0 Kudos
Message 1 of 3
(2,847 Views)
Solution
Accepted by Andrea12345

Hi Andrea,

 

You can use the Split method to get parts of your filename.

Then recompose the name of your file by concatenating every strings you need.

Finally rename your file.

 

Feel free to ask if something is unclear 🙂

 

CLAMaxime -- Kudos are a great way to say thank you
Message 2 of 3
(2,821 Views)

Thanks for the reply!

 

I have used the split method as you have suggested, here is how I have done it:

 

'rename and save processed file
dim Newname, Splitname, Suffix, Myarray, i
Suffix = " - processed@10kHz"
SplitName = Split(datafilename, ".", -1, vbTextCompare)
MyArray = array (Splitname(0),suffix,".",Splitname(1))
NewName = Join (Myarray)
data.Root.Name = Newname
call datafilesave (NewName,"TDMS")

0 Kudos
Message 3 of 3
(2,793 Views)