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,546 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 46,801 Reputation points
    2020-07-27T01:53:07.933+00:00

    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

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.