Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My initial script is below. I've no doubt this can be drastically improved on.</p> <pre><code># Load TagLib DLL [void] [Reflection.Assembly]::LoadFrom($TagLibDllPath) # Get all videos in the given directory $videoFiles = Get-ChildItem $directoryPath -Include *.avi -Recurse -Force if (($videoFiles -eq $null) -or (($videoFiles | Measure-Object).Count -eq 0)) { Throw "Given directory $directoryPath does not contain any videos!" } else { $videos = @() foreach($videoFile in $videoFiles) { $video = [TagLib.File]::Create($videoFile.FullName) $videoDetails = new-object object; $videoName = [System.IO.Path]::GetFileNameWithoutExtension($videoFile.FullName) Add-Member -in $videoDetails noteproperty "Title" $videoName Add-Member -in $videoDetails noteproperty "Duration" $video.Properties.Duration.TotalMinutes $videos+= $videoDetails; } $videos = $videos | Sort-Object Duration -descending if (!(Test-Path $outputFile)) { New-Item -Path $outputFile -Type "file" -Force | out-null } $newLine = [System.Environment]::NewLine $fileHeader = "Duration (minutes) Title" $fileContents = $fileHeader, $newLine foreach($video in $videos) { $outputString = [string]::Format("{0}`t`t`t`t`t {1}", "{0:N0}" -f $video.Duration, $video.Title) $fileContents = $fileContents + $outputString } Set-Content -path $outputFile -value $fileContents } </code></pre> <p>Please note the dependency on the <a href="http://developer.novell.com/wiki/index.php/TagLib_Sharp" rel="nofollow noreferrer">TagLib Sharp</a> library. Both <code>$directoryPath and</code>$outputFile are parameters passed to the script.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload