Clear-Host #### Search start folder #### $Folder = 'D:\Videos' #### Video formats to search for. Add others as you see fit. #### $VideoFormats = @('*.avi','*.mkv','*.mp4') #### Snapshot format. jpg or png #### $SnapshotFormat = 'jpg' #### Path to the VLC player executable #### $Player = 'C:\Program Files (x86)\VideoLAN\VLC\vlc.exe' #### The extra parameters needed to open video fullscreen and close automatically when finished #### $CommandLineParameters = '--fullscreen --play-and-exit --no-video-title-show' #### Path to the folder to store the generated ini-files #### $IniPath = 'C:\Progs\STFE\Config\Config09\' #### Iterate all video files in selected folder #### $Files = Get-ChildItem -Path $Folder -Recurse -Include $VideoFormats foreach ($File in $Files) { #### Get duration of video-file from Windows length column ### $LengthColumn = 27 $objShell = New-Object -ComObject Shell.Application $objFolder = $objShell.Namespace($Folder) $objFile = $objFolder.ParseName($File.Name) $Duration = $objFolder.GetDetailsOf($objFile, $LengthColumn) try{ $Seconds = ([TimeSpan]::Parse($Duration)).TotalSeconds $StartPosition = [math]::Floor($Seconds/2) } catch{ Write-Host 'Duration not available. Setting start position to 1.' -ForegroundColor Red $StartPosition = 1 } #### Create jpg snapshot of the video and put in the same folder as the video. Overwrite if already exist. #### $ArgumentsArray = @() $ArgumentsArray += '"' + $File.FullName + '"' $ArgumentsArray += '--no-video-title-show' $ArgumentsArray += '--start-time=' + $StartPosition $ArgumentsArray += '--run-time=1' $ArgumentsArray += '--rate=1' $ArgumentsArray += '--video-filter=scene' $ArgumentsArray += '--aout=dummy' $ArgumentsArray += '--scene-width=320' $ArgumentsArray += '--scene-height=200' $ArgumentsArray += '--scene-format=' + $SnapshotFormat.TrimStart('*.') $ArgumentsArray += '--scene-prefix=' + $File.BaseName $ArgumentsArray += '--scene-path="' + $File.Directory + '"' $ArgumentsArray += '--scene-replace' $ArgumentsArray += 'vlc://quit' Write-Host $ArgumentsArray -ForegroundColor Yellow Start-Process -FilePath "$Player" -ArgumentList $ArgumentsArray -wait Write-Host 'Start position: ' -ForegroundColor White -NoNewline Write-Host $StartPosition -ForegroundColor Cyan Write-Host '' #### Set title of the entry. Comment/uncomment the various title-variants below as you see fit. #### #### Get filename without path and extension #### $Title = $File.BaseName #### Replace - and _ with spaces #### #$Title = $Title.Replace('_', ' ').Replace('-',' ') #### Captialize first word in title #### #$Title = $Title.SubString(0,1).toUpper() + $Title.SubString(1).toLower() #### Captialize every word in title #### #$Title = (Get-Culture).TextInfo.ToTitleCase($Title) #### Set preview image of the entry. Comment/uncomment the various preview-variants below as you see fit. #### #### No preview image #### #$PreviewImage = '' #### Add snapshot as preview image #### $PreviewImage = '"' + $File.DirectoryName + '\' + $File.BaseName + '.' + $SnapshotFormat.TrimStart('*.') + '"' #### Use the video itself as preview image #### #$PreviewImage = '"' + $File.FullName + '"' #### Write info to ini-file #### $IniFile = $IniPath.TrimEnd('\ ') + '\' + $Title + '.ini' $Stream = [System.IO.StreamWriter] $IniFile $Stream.WriteLine('[Game]') $Stream.WriteLine('DisplayName=' + $Title + ' - ' + $Duration) $Stream.WriteLine('Program=' + $Player) $Stream.WriteLine('Parameters=' + '"' + $File.FullName + '" ' + $CommandLineParameters) $Stream.WriteLine('Wait=1') $Stream.WriteLine('PreGameProgram=') $Stream.WriteLine('HidePreProgram=1') $Stream.WriteLine('Launch2=0') $Stream.WriteLine('UseKillFunction=0') $Stream.WriteLine('UseStartFunction=0') $Stream.WriteLine('Image=' + $PreviewImage) $Stream.WriteLine('LaunchImage=') $Stream.Close() }