04-24-2018 03:56 AM
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
Solved! Go to Solution.
04-24-2018 07:44 AM
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 🙂
04-25-2018 02:18 PM
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")