Continuing my post on Filtering files by their metadata (extended properties), and a question raised by Ankor in the comments section, I decided to quickly wrap up a new function (based on the one in the post) that simply adds the specified extended properties as new note properties to the object in the pipeline. As we would be reading only the required extended properties it would run much faster, and we could simply filter those objects later using the Where-Object (or with any other comparison statement).

The functions’ code is:

And you can use it:


# Rating: 19
dir -Path G:MusicaMSpecial | Add-ExtendedAttribute -ExtendedAttributeId 19 |
    Where-Object { $_.Rating -eq ‘2 Stars’ } | Copy-Item -Destination G:Temp

Or:


# Genre: 16
dir -Path G:MusicaMSpecial | Add-ExtendedAttribute -ExtendedAttributeId 16 |
    Where-Object { $_.Genre -eq ‘Rock’ } | Copy-Item -Destination G:Temp

Thank you Ankor for raising the question

HTH,
Martin.

Advertisements