# Reading OpusMetaInformation powershell

**URL:** https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850
**Category:** Help & Support
**Created:** [March 10, 2019, 10:49pm UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850 "2019-03-10T22:49:18Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![wowbagger](https://resource.dopus.com/user_avatar/resource.dopus.com/wowbagger/32/25880_2.png) [@wowbagger](https://resource.dopus.com/u/wowbagger)
#### Post date: [March 10, 2019, 10:49pm UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850/1 "2019-03-10T22:49:18Z")

</div>

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

```auto
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.

```auto
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?

---

<div class="post-metadata">

### Author: ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)
#### Post date: [March 10, 2019, 10:55pm UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850/2 "2019-03-10T22:55:29Z")

</div>

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

---

<div class="post-metadata">

### Author: ![wowbagger](https://resource.dopus.com/user_avatar/resource.dopus.com/wowbagger/32/25880_2.png) [@wowbagger](https://resource.dopus.com/u/wowbagger)
#### Post date: [March 10, 2019, 11:16pm UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850/3 "2019-03-10T23:16:57Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)
#### Post date: [March 10, 2019, 11:20pm UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850/4 "2019-03-10T23:20:10Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![wowbagger](https://resource.dopus.com/user_avatar/resource.dopus.com/wowbagger/32/25880_2.png) [@wowbagger](https://resource.dopus.com/u/wowbagger)
#### Post date: [March 11, 2019, 12:47am UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850/5 "2019-03-11T00:47:40Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)
#### Post date: [March 11, 2019, 1:00am UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850/6 "2019-03-11T01:00:22Z")

</div>

Not to read the labels

---

<div class="post-metadata">

### Author: ![wowbagger](https://resource.dopus.com/user_avatar/resource.dopus.com/wowbagger/32/25880_2.png) [@wowbagger](https://resource.dopus.com/u/wowbagger)
#### Post date: [March 11, 2019, 1:37am UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850/7 "2019-03-11T01:37:41Z")

</div>

Ok. thanks mate.

---

<div class="post-metadata">

### Author: ![smallscript](https://resource.dopus.com/letter_avatar_proxy/v4/letter/s/e47774/32.png) [@smallscript](https://resource.dopus.com/u/smallscript)
#### Post date: [March 25, 2020, 11:29pm UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850/8 "2020-03-25T23:29:39Z")

</div>

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"

```auto
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.,

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

```

> - [Windows Summary Information Stream](https://docs.microsoft.com/en-us/windows/win32/msi/summary-property-descriptions)
> - [Description of that stream](https://sedna-soft.de/articles/summary-information-stream/)  
> `afm .%H(fs-read('.default.md:\x05SummaryInformation'),,16)`  
> Will get you access to the **comments** , but it is a bit more complicated to decode. _Hint: The comments are at the end typically if no other fields._

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

---

<div class="post-metadata">

### Author: ![infernoz](https://resource.dopus.com/letter_avatar_proxy/v4/letter/i/35a633/32.png) [@infernoz](https://resource.dopus.com/u/infernoz)
#### Post date: [June 19, 2020, 8:02am UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850/9 "2020-06-19T08:02:12Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jkooks](https://resource.dopus.com/letter_avatar_proxy/v4/letter/j/4af34b/32.png) [@jkooks](https://resource.dopus.com/u/jkooks)
#### Post date: [March 3, 2025, 7:42pm UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850/10 "2025-03-03T19:42:54Z")

</div>

Is there any update on the easiest way to do this? I am trying to get the status and label information for a tool outside of DOpus using Python but am having a hard time doing so.

Any help will be appreciated!

---

<div class="post-metadata">

### Author: ![PassThePeas](https://resource.dopus.com/user_avatar/resource.dopus.com/passthepeas/32/50972_2.png) [@PassThePeas](https://resource.dopus.com/u/PassThePeas)
#### Post date: [March 3, 2025, 7:48pm UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850/11 "2025-03-03T19:48:55Z")

</div>

Maybe a custom command (that writes to a temp file) that would be called from python via dopusrt ?  
A bit cumbersome though ....  
Or a script that outputs information in a structured output file that you can feed to your python script (more steps and more manual).

---

<div class="post-metadata">

### Author: ![jkooks](https://resource.dopus.com/letter_avatar_proxy/v4/letter/j/4af34b/32.png) [@jkooks](https://resource.dopus.com/u/jkooks)
#### Post date: [March 3, 2025, 10:35pm UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850/12 "2025-03-03T22:35:03Z")

</div>

Do you know how to get the information in the first place? I haven't been able to find anything in the dopusrt documentation that will allow access to the information. Also haven't found anything in the documentation that allows scripts or plugins to access it, either.

---

<div class="post-metadata">

### Author: ![PassThePeas](https://resource.dopus.com/user_avatar/resource.dopus.com/passthepeas/32/50972_2.png) [@PassThePeas](https://resource.dopus.com/u/PassThePeas)
#### Post date: [March 3, 2025, 11:11pm UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850/13 "2025-03-03T23:11:32Z")

</div>

Metadata can be accessed from the `item` object ([Item [Directory Opus Manual]](https://docs.dopus.com/doku.php?id=reference:scripting_reference:scripting_objects:item)) through the `metadata` property.  
Then you can go through the metadata itself with this `metadata object` ([Metadata [Directory Opus Manual]](https://docs.dopus.com/doku.php?id=reference:scripting_reference:scripting_objects:metadata)).

For the labels, even though I never tested this, using the `Labels` method of the `item` object might lead you to what you need.

The item object itself if easily retrievable from selection, or from scanning a folder, or from its path (first from the scriptCommandData object passed into the entry point of the command, last two from `FSUtil.ReadDir` and `FSUtil.GetItem`)

---

<div class="post-metadata">

### Author: ![jkooks](https://resource.dopus.com/letter_avatar_proxy/v4/letter/j/4af34b/32.png) [@jkooks](https://resource.dopus.com/u/jkooks)
#### Post date: [March 3, 2025, 11:41pm UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850/14 "2025-03-03T23:41:00Z")

</div>

Thank you! That information is very helpful. I'll let you know if I end up having any other questions, but hopefully this will solve my dilemma.

---

<div class="post-metadata">

### Author: ![PassThePeas](https://resource.dopus.com/user_avatar/resource.dopus.com/passthepeas/32/50972_2.png) [@PassThePeas](https://resource.dopus.com/u/PassThePeas)
#### Post date: [March 4, 2025, 12:01am UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850/15 "2025-03-04T00:01:20Z")

</div>

Another thought : Depending on what the python script is doing, you might have to consider one of the three options : 1) calling Opus (custom command in JScript ... or VB) from Python; 2) calling Python from Opus ; 3) Doing everything from Opus.

EDIT: As said before, option 1) is probably better to be done via dopusrt.exe and a file with content result. Note that dopusrt.exe calls are asynchronous: once called, you get back to the caller even if the command called takes several minutes to execute (even seconds might be a problem to address). And you don't have the ability to get any content in return from dopusrt.exe.

---

<div class="post-metadata">

### Author: ![jkooks](https://resource.dopus.com/letter_avatar_proxy/v4/letter/j/4af34b/32.png) [@jkooks](https://resource.dopus.com/u/jkooks)
#### Post date: [March 4, 2025, 12:11am UTC](https://resource.dopus.com/t/reading-opusmetainformation-powershell/31850/16 "2025-03-04T00:11:48Z")

</div>

Option 1 is probably best for my purpose but I may also look into option 3. And thanks for the note about it being asynchronous! Fortunately the application I am writing is already multi-threaded, so the thread that would be talking to DOpus can wait around until the temp file is done being written to without blocking much.
