DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Moving File Comments

I have a Diadem script that converts MDF to TDM.  The problem is, the program that writes the MDF's uses the files "comments" property to store information about the file, so when I save the TDM, those comments are lost.  I would like to move the file comments from the MDF file to the TDM file.  I can use a shell object and the Folder.GetDetailsOf method to read the comments, but I can't seem to figure out how to write them. 

 

I know I could read the comment into a custom property inside the TDM file, but it's quite convenient to see the comments in windows explorer.  Any thoughts? 

0 Kudos
Message 1 of 2
(1,162 Views)

I am unable to replicate your problem.  I found a MF4 file online and loaded it with the MDF4 DataPlugin version 21.5.0f139.  Then I saved it to a TDM file, and then loaded it again after clearing the Data Portal.  You state that you want to preserve the "comments" property.  This file doesn't isn't in that MF4 file.  Did you mean "description" rather than "comments"?  I didn't see any property in the MF4 file that was not in the TDM file.  In fact, in the script below I go through all of the metadata (properties) in the file and compare what is in the MF4 file to what is in the TDM file, and they are the same.

 

Spoiler

'-------------------------------------------------------------------------------
'-- VBS script file
'-- Author: Mechatronic Solutions LLC
' Mark W Kiehl
' www.SavvyDiademSolutions.com
' www.SavvyDIAdemPySolutions.com/
' www.MechatronicSolutionsLLC.com
'-- License: http://www.savvydiademsolutions.com/license.php
'-- Comment: Forum Msg 29534
'
'-------------------------------------------------------------------------------
Option Explicit
Call LogFileDel
Dim file_path_mf4, file_path_tdm, metadata, prop, chn_grp, chn, metadata_count

'Go to this URL: https://www.asam.net/standards/detail/mdf/wiki/
'And then under 'Downloads' on the page is the file listed 'ECU_Description.zip'. Download the .zip file
'from this link: https://www.asam.net/index.php?eID=dumpFile&t=f&f=2132&token=1672c6611f14141ae705140149a9401141821de...
'Extract out the file 'ASAP2_Demo_V171.mf4' and then reference it in the file_path_mf4 reference below...
file_path_mf4 = "D:\DIAdem\customers\MechatronicSolutionsLLC\BulkImport\SampleDataFiles\MDF4 ASAM\ASAP2_Demo_V171.mf4"
Call Data.Root.Clear()
'Below uses the MDF4 DataPlugin version 21.5.0f139 available for download here: https://www.ni.com/en-us/support/downloads/dataplugins/download.asam-e-v--dataplugin-for-mdf4.html#4...
Call DataFileLoad(file_path_mf4, "MDF4", "Load|ChnXYRelation")

'Get a summary of all the metadata in the Data Portal (for comparison to TDM later)...
metadata = "": metadata_count = 0
For Each prop In Data.Root.Properties
metadata = metadata & "'" & prop.Name & "' = '" & prop.Value & "'|"
metadata_count = metadata_count + 1
Next
For Each chn_grp In Data.Root.ChannelGroups
For Each prop In chn_grp.Properties
metadata = metadata & "'" & prop.Name & "' = '" & prop.Value & "'|"
metadata_count = metadata_count + 1
Next
For Each chn In chn_grp.Channels
For Each prop In chn.Properties
metadata = metadata & "'" & prop.Name & "' = '" & prop.Value & "'|"
metadata_count = metadata_count + 1
Next
Next
Next
Call LogFilewrite("metadata_count = " & metadata_count)
Call LogFileWrite("len(metadata) = " & len(metadata))

'Save the file in the Data Portal to .TDM format with the same path and filename (different filename extension)...
file_path_tdm = NameSplit(file_path_mf4,"P") & NameSplit(file_path_mf4,"N") & ".tdm"
If FileExist(file_path_tdm) Then Call FileDelete(file_path_tdm, False, False)
Call DataFileSave(file_path_tdm, uCase(NameSplit(file_path_tdm,"E")), True)

'Load the TDM file
Call Data.Root.Clear()
Call DataFileLoad(file_path_tdm, uCase(NameSplit(file_path_tdm,"E")), "Load|ChnXYRelation")

'Get a summary of all the metadata in the Data Portal (for comparison to TDM later)...
metadata = "": metadata_count = 0
For Each prop In Data.Root.Properties
metadata = metadata & "'" & prop.Name & "' = '" & prop.Value & "'|"
metadata_count = metadata_count + 1
Next
For Each chn_grp In Data.Root.ChannelGroups
For Each prop In chn_grp.Properties
metadata = metadata & "'" & prop.Name & "' = '" & prop.Value & "'|"
metadata_count = metadata_count + 1
Next
For Each chn In chn_grp.Channels
For Each prop In chn.Properties
metadata = metadata & "'" & prop.Name & "' = '" & prop.Value & "'|"
metadata_count = metadata_count + 1
Next
Next
Next
Call LogFilewrite("metadata_count = " & metadata_count)
Call LogFileWrite("len(metadata) = " & len(metadata))

 

0 Kudos
Message 2 of 2
(1,117 Views)