dimanche 29 janvier 2017

Get-Random increased randomness HELP Powershell

I am in need of a little help as to increasing the randomness of get-random thus not repeating so often.

I have been using this with powershell:

$formats =
@("*.mpg")
$dir = Split-Path $MyInvocation.MyCommand.Path
gci "$dir\*" -include $formats | Get-Random -Count 1 |
Invoke-Item

My application is to have a in home virtual television channel that randomly selects 1 file from multiple folders at 6am and plays them all day until midnight, powers off and starts up, repeating the process daily. The problem I am finding is that whatever the get-random command uses had a tendency to choose the exact same file often. Thus after months of running this script, I am seeing the exact same movies chosen day after day and some that are never chosen. I'm guessing because the get-random is using the clock as it's factor for choosing a number?

Is there a way to increase the odds of getting a broader selection of files .mpg's in this instance and less of a repeat of the same .mpg's chosen?

My other option was to find a script that would keep track of the .mpg's chosen and "mark" them, or sort by date accessed and not play the same file twice, until all files of a particular folder have been played once; then "unmarking" all the files and starting over. To me that sounds like advanced scripting that I just don't have the knowledge to procure on my own.

Any insight into my dilemma would be vastly appreciated. Any questions about my specifics to help you ascertain a conclusion to this query will be forthcoming.




Aucun commentaire:

Enregistrer un commentaire