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
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?
-
David Stokes 96 Reputation points
2020-07-26T11:44:38.053+00:00
5 additional answers
Sort by: Most helpful
-
Rich Matheisen 46,801 Reputation points
2020-07-22T19:11:35.82+00:00 Does this work?
how-to-search-windows-search-indexed-files-with-powershell -
Venkita Ramanan, Ramu 56 Reputation points
2020-07-23T02:56:37.347+00:00 Are you looking for this ? 1928da03047aee4167fabee0f501c72d
-
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.
-
Rich Matheisen 46,801 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