Reading OpusMetaInformation powershell

In Powershell you can read an ADS using the get-content command with the -stream flag.

Get-Item -Path 'D:\temp\a.txt' -stream * 

   FileName: D:\temp\a.txt

Stream                   Length
------                   ------
:$DATA                   612035
OpusMetaInformation         20

But if i try to read the stream it errors.

Get-Content -Path 'D:\temp\a.txt'  -stream OpusMetaInformation
Get-Content : Could not open alternate data stream 'OpusMetaInformation' of file 'D:\temp\a.txt'.
At line:1 char:1
+ Get-Content -Path $file -stream OpusMetaInformation
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (D:\temp\a.txt:String) [Get-Content], FileNotFoundException
    + FullyQualifiedErrorId : GetContentReaderFileNotFoundError,Microsoft.PowerShell.Commands.GetContentCommand

What would be the best way to access the steams (read write and edit) out side of dopus?

What do you want to do with them? The format they're in isn't that easy to edit by hand.

I have zips of photo sets. Holidays, bday parties and such. Some have ratings and some have tags.

I want to:

  • Read the zip and look for a tag.
  • Depending on the value preform an action that will result in replacing the zip with a new one.
  • Copy tags from old zip to new zip.
  • Add Tag to indicate processed.

I want to produce a script that would process all files, hence considering PowerShell.
I could make a Dopus script. I am also considering hacking the comic book script, as there is some cross over (and it might add some value to that script for others).

Doing it from an Opus script would be much easier, since that gives you access to the data. You could have the Opus script run a PowerShell script/command and tell if the tags etc. if you want to do most of it in PS.

Could I use the DOpusRT to do it from outside of Dopus?

Not to read the labels

Ok. thanks mate.

If you're really determined, the [NTFS file-stream] format looks as follows:
Windows Terminal

Given a rating of "5 stars" and a tags of "touched"

afm .%H(fs-read('.default.md:\x07OpusMetaInformation'),,16)
1400000000000000
6300000000000000
0900000074006F00
7500630068006500
640000000000

The rating is at offset 16 => "63"

63~00000000000000~

The tags => "touched" is a UNICODE string whose UInt32 (DWORD) length starts at offset 32

09000000~7400~6F00~7500~6300~6800~6500~6400~0000~0000
length 9-chars, 0x74, 0x75, 0x63, 0x68, 0x65, 0x64, 0, 0

E.g.,

afm .(`$:%H('touched\x00\x00') length: $:sizeof('touched\x00\x00')`)
746F75636865640000 length: 9

You can see [xattr] file streams on an NTFS-File by typing dir /R at a console [wt.exe or cmd.exe] command-line.

1 Like

From some testing, via nirsoft's "AltenateStreamView" and "HxD", the structure actually appears to be:

Header:

  • 00:
    14 00 00 00 00 00 00 00
    : Probably an offset to the start of the Optional Text section, possibly to allow further expansion of the header, so probably not a good idea to ignore it!
  • 08:
    63 00 00 00
    : Rating: 0x01 = 1 star, 0x19 (25) = 2 star, 0x32 (50) = 3 star, 0x48 (75) = 4 star, 0x63 (99) = 5 star
  • 0C: cc cc cc cc
    : if zero, no comment, otherwise number of comment chars, including NUL
  • 10: tt tt tt tt
    : if zero, no tags, otherwise total chars length, including NUL, and end of tags NUL

Optional Text:

  • 14: 16-bit LE Unicode chars
    : any comment chars, then any tag chars