DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Script to Read the Name of the File Loaded in the Data Portal

Solved!
Go to solution

Hello,

I thought this would be an easy thing to figure out, but I'm just coming up with dead-ends. I'm trying to save a file through script and just use the name of the file loaded into the Data Portal as the name of the new TDM I want to create. These will both be in the same folder.

 

If my filename is 20210406Data.sif I would like the TDM created to be 20210406Data.TDM.

 

Here's what the final code would be if I wanted to hardcode the name each time

 

Call DataFileSave(DataReadPath & "20210406Data.TDM", "TDM", True)

 

I'm hoping there is some command like "FileName" so I can use a script like this.

 

Call DataFileSave(DataReadPath & FileName &".TDM", "TDM", True) 

 

Thanks,

Tyler

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

Hi TW_Test,

 

Please have a look at this code:

 

dim sFileName, sFullFileName

sFullFileName = "D:\test\TestToSplitFileName.SIF"
sFileName = FileNameSplit(sFullFileName, "N")
msgbox sFileName

sFullFileName = DataReadPath & sFileName & ".TDM"
msgbox sFullFileName

 

Greetings

Walter

0 Kudos
Message 2 of 4
(1,329 Views)

Thanks Walter for you reply.

 

It looks like in your script I still have to code in the name of each file. I'm hoping to automate saving the TDM file using the script. Say I have data in 15 different folders that I want to quickly work through. My thought process was to drop the .sif files into the data portal, run a script that does a bunch of operations on the data and then finishes by saving the file as a TDM for later editing if needed. Having the script automatically use the existing .sif filename would make it easier to run through multiple folders of data.

 

If there is a command for replacing the "D:\test\TestTOSplitFileName.sif" with whatever the current file and path is then the FileNameSplit command would work great.

 

Thanks

0 Kudos
Message 3 of 4
(1,323 Views)
Solution
Accepted by topic author TW_Test

Looks like I found the solution with more searching on the forum. Data.Root.Name gives me what I wanted.

 

Call DataFileSave(DataReadPath & Data.Root.Name & ".TDM", "TDM", True)

 

Thanks

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