question

DavidStokes-5699 avatar image
0 Votes"
DavidStokes-5699 asked RichMatheisen-8856 answered

Powershell - how to interrogate Windows Index file

On my W10 desktop I have about 3000 mp3 files in folders organised by Genre. I would like to mirror all the files which have a Rating of >3 to my NAS which runs a media server.
I understand that because mp3 files are compressed it would not be practical to search each file for the Rating. That it would be better to search through the Windows Index file.
Then for each music entry in Windows Index with a Rating >3, run Robocopy in Mirror mode to build a mirror on the NAS - organised by Genre.
I have written about half a dozen Powershell programs so am still a novice.
Can anyone give me a starter for how to search the Windows Index file and then generate a Robocopy command?

windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DavidStokes-5699 avatar image
0 Votes"
DavidStokes-5699 answered RichMatheisen-8856 commented

Thanks guys, based upon your leads I have found the answer.
Get-IndexedItem does what I am asking for. I used the following parameters:
Get-IndexedItem -Path d:/audio/music -Recurse -Filter "Kind = 'Music' AND Genre = 'Folk' AND RatingText = '4 Stars' " | copy -destination f:\SearchIndex\Folk
I will then mirror the output folder to my NAS using Robocopy.
The only problem remaining is that I cannot get the AND/OR SQL combination to work in the Get-IndexedItem 'Filter' parameter. As in:
-Filter "Kind = 'Music' AND Genre = 'Folk' AND (RatingText = '4 Stars' OR RatingText = '5 Stars')"
I believe that is valid in SQL but causes an error when used in the Get-IndexedItem commandlet.
Thanks again, David

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I had a problem getting a TSQL query to work with the System.Rating too. Basically I just wound up retrieving the file's location and rating from the index and checking the rating with Powershell.

I tried posting an answer to your question yesterday but I got an error saying I wasn't authorized. Go figure. Let's see if this comment is accepted.

0 Votes 0 ·
RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

VenkitaRamananRamu-2139 avatar image
0 Votes"
VenkitaRamananRamu-2139 answered

Are you looking for this ? 1928da03047aee4167fabee0f501c72d


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DavidStokes-5699 avatar image
0 Votes"
DavidStokes-5699 answered

Thanks guys, both suggestions may go some way towards helping but unfortunately my knowledge limits my ability to fully understand the code. But it appears to me that the code searches for paths and filenames? I need to search within the attributes of Windows Index entries.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered RichMatheisen-8856 edited

If you want to search the rating of a MP3 you have to change the WHERE clause in the SQL. Something like this should work:

$rs.Open("SELECT System.ItemPathDisplay,System.Rating FROM SYSTEMINDEX WHERE System.Rating LIKE '" + $Pattern + "' AND System.ItemPathDisplay LIKE '" + $path + "'" , $con)

I haven't tried that, though.

You might want to have a look at the way the ratings are defined, too.
props-system-rating


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

You can modify this function to process the ratings any way you like. And to use your SQL SELECT to extract whatever KIND , GENRE, etc.

See attached13807-searchrating.txt



searchrating.txt (1.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.