Skip to content

Instantly share code, notes, and snippets.

@rytsikau
Last active September 4, 2020 07:18
Show Gist options
  • Save rytsikau/2f7c5ee5ede44456603ffb1a89d43b2b to your computer and use it in GitHub Desktop.
Save rytsikau/2f7c5ee5ede44456603ffb1a89d43b2b to your computer and use it in GitHub Desktop.
Get media info for *.mp4 files with FFprobe and standard Windows shell
"--------------------------------------------------"
set-executionpolicy unrestricted -scope currentuser
$erroractionpreference = "silentlycontinue"; remove-variable *; $erroractionpreference = "continue"
$objShell = new-object -comobject shell.application
$folderFFprobe = "C:\Program Files\FFmpeg"
$folderMedia = "D:\My Documents"
"Get media info for *.mp4 files with FFprobe and standard Windows shell"
"Folder: $folderMedia"
"--------------------------------------------------"
$files = get-childitem $folderMedia -file -recurse | ?{ $_.name -like "*.mp4" } | %{ $_.fullname }
if (!(test-path "$folderMedia\info")) { new-item -itemtype directory "$folderMedia\info" | out-null }
foreach($file in $files)
{
$fileFolder = split-path -path $file
$fileName = split-path -leaf $file
"`t$fileName"
$resultPath = "$folderMedia\info\$fileName.ffprobe"
if (!(test-path $resultPath))
{
$result = ""
$ffprobeStr = "`"$folderFFprobe\ffprobe.exe`" -v quiet -show_format -show_streams `"$file`""
$result = cmd /c $ffprobeStr
$result | out-file -literalpath $resultPath
}
$resultPath = "$folderMedia\info\$fileName.shell"
if (!(test-path $resultPath))
{
$result = ""
$objFolder = $objShell.namespace($fileFolder)
$objFile = $objFolder.parsename($fileName)
for ($i = 0; $i -le 999; $i++)
{
$value = $objFolder.getdetailsof($objFile, $i)
if ($value -notlike "")
{
$result += $objFolder.getdetailsof($null, $i) + " ($i): $value`n"
}
}
$result | sort | ?{ $_.trim() -ne "" } | out-file -literalpath $resultPath
}
}
$erroractionpreference = "silentlycontinue"; remove-variable *; $erroractionpreference = "continue"
"--------------------------------------------------"
"Ready!"
"--------------------------------------------------"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment