Powershell - how to interrogate Windows Index file

David Stokes 96 Reputation points
2020-07-22T16:08:53.53+00:00

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
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,444 questions
0 comments No comments
{count} votes

Accepted answer
  1. David Stokes 96 Reputation points
    2020-07-26T11:44:38.053+00:00

    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


5 additional answers

Sort by: Most helpful
  1. Rich Matheisen 45,591 Reputation points
    2020-07-22T19:11:35.82+00:00
    0 comments No comments

  2. Venkita Ramanan, Ramu 56 Reputation points
    2020-07-23T02:56:37.347+00:00

    Are you looking for this ? 1928da03047aee4167fabee0f501c72d

    0 comments No comments

  3. David Stokes 96 Reputation points
    2020-07-23T15:21:28.433+00:00

    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.

    0 comments No comments

  4. Rich Matheisen 45,591 Reputation points
    2020-07-23T19:25:38.293+00:00

    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

    0 comments No comments