0

I would like to extract an unusual file property that a software package (OrcaFlex) adds when it creates a file. In Windows Explorer, when I hover my cursor over the file listing such as SomeSimulation.sim in the first screenshot below, a popup window appears with properties including 'Model state'. Here I learned these are called infotips. I want to retrieve the Model state value (the string "Time domain dynamics complete") using Perl or any other command line language. How do I do that? I am using Windows 7 and James' comment helped me see that I will have to use this, perhaps like this.

file listing

KAE
  • 1,849
  • 8
  • 32
  • 48
  • I believe this is handled by a shell extension implementing the **GetInfoTip** command but I don't it's realistically possible to call it outside of Explorer without a lot of work. – James P Jun 03 '16 at 14:24
  • Is this an example of using GetInfoTip to pull out the info from C++? https://msdn.microsoft.com/en-us/library/windows/desktop/bb761357%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 and is this an example in Python? http://blog.gmane.org/gmane.comp.python.windows/month=20090501/page=4 I want to know I am pointed in the right direction since I don't know much C++ or python. – KAE Jun 03 '16 at 14:40
  • 1
    Unfortunately not, they are about implementing the function in a shell extension. Something like this might be relevant though: http://stackoverflow.com/questions/5721700/call-windows-explorer-shell-extension. – James P Jun 03 '16 at 14:56
  • 1
    ....or, this: http://superuser.com/questions/363278/is-there-a-way-to-get-file-metadata-from-the-command-line – Shoeless Jun 03 '16 at 14:59

2 Answers2

1

I'm one of the authors of OrcaFlex. With absolutely no warranty the following Python code will hack out what you need.

import struct

def readModelStateText(fileName):
    with open(fileName, 'rb') as f:
        content = f.read(0x4000) # hope that the text appears this early in the file
    signature = b'\xff\xfa\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
    index = content.find(signature)
    if index == -1:
        return '<model state not found>'
    index += len(signature) + 2 # skip over block length
    stringLength = struct.unpack('<H', content[index:index + 2])[0]
    index += 2
    return content[index:index + stringLength].decode('utf-8')

This hunts for a specific block in the file with knowledge of the block header signature. It is plausible (very unlikely I suspect) that the code will find the body of an earlier block that matches the signature. And there are other ways that this code might fail.

I'm just offering it because it is possibly useful, but with a hefty caveat emptor.

David Heffernan
  • 1,182
  • 1
  • 6
  • 14
  • I no longer have OrcaFlex access so can't confirm, but appreciate the answer! – KAE Jun 26 '17 at 18:42
  • 1
    I do have OrcaFlex access ;-) and it works well!! It came up because another user asked for the same functionality and referred to this question. So I thought I may as well answer here too. – David Heffernan Jun 26 '17 at 18:52
0

My smart coworker noticed that the string "Time domain dynamics complete" is actually in the binary file early on. So I used grep without interacting with Windows which is a relief,

head -10 SomeSimulation.sim | grep "Time domain dynamics complete"
KAE
  • 1,849
  • 8
  • 32
  • 48