Tuesday, September 10, 2013

Just a few shell games... shellproperty.exe and Raymond's Audio file metadata setter

Matthew van Eerde's web log - shellproperty.exe - set/read string properties on a file from the command line

Yesterday Raymond Chen blogged a "Little Program" which could edit audio metadata. As it happens, I have a similar tool I threw together which accepts a property key and a string property value to update a property, or can read a string or string-vector property.

Usage:

>shellproperty
shellproperty read <key> from <filename>
shellproperty set <key> to <string> on <filename>

Here's an example _fixup.bat script I use to set audio metadata on my copy of Giuseppe Sinopoli's recording of Madama Butterfly, to help distinguish it from other recordings of the same opera that I have.

@echo off
dir /s /b "I *.mp3" | xargs /addquotes shellproperty set PKEY_Music_AlbumTitle to "Madama Butterfly - Sinopoli / Freni: 1 of 3" on
dir /s /b "II *.mp3" | xargs /addquotes shellproperty set PKEY_Music_AlbumTitle to "Madama Butterfly - Sinopoli / Freni: 2 of 3" on
dir /s /b "III *.mp3" | xargs /addquotes shellproperty set PKEY_Music_AlbumTitle to "Madama Butterfly - Sinopoli / Freni: 3 of 3" on

Source and amd64/x86 binaries attached, but in substance it's very similar to Raymond's "Little Program".

..." [GD: Click through for the source ;]

The Old New Thing - Programmatically editing the metadata of an audio file

Today's Little Program edits the metadata of an audio file, ostensibly to correct a spelling error, but really just to show how it's done.

Today's smart pointer class library is... (rolls dice)... CComPtr!

We open with two helper functions which encapsulate the patterns

  • Get property from property store
    1. Call IProperty­Store::Get­Value
    2. Convert PROPVARIANT into desired final type
    3. Destroy the PROPVARIANT
  • Set property in property store
    1. Create a PROPVARIANT
    2. Call IProperty­Store::Set­Value
    3. Destroy the PROPVARIANT

... [GD: Again, click through for the source]

Two little command line app's that not only teach, but look useful in their own rights. And who doesn't like hacking document metadata properties? :P

No comments: