can powershell report audio/video time length

Traceyad2032
Traceyad2032 Member Posts: 22 Troubleshooter

I discovered that powershell came with the acer laptop (I am not a programmer, but I have used simple batch files in times past (btw the os is Win7 Home).

Someone posted what I pasted below, but the time-length (hh:mm:ss) does not display (maybe called the duration).

Can someone tell me how I can report the file data including the audio/visual time length?

It appears the sample below calls the file size (bytes) the length and the dir cmd calls (hh:mm:ss) the length.

Also, can this be converted to a batch file or some kind of powershell script to be run in powershell when desired?

Pasting the code into powershell works as-is with a lot of error messages.

Please advise.

Thanks, Tracey

$Directory = "D:\My Source Folder"
$Shell = New-Object -ComObject Shell.Application
Get-ChildItem -Path $Directory -Recurse -Force | ForEach {
$Folder = $Shell.Namespace($.DirectoryName)
$File = $Folder.ParseName($
.Name)
$Duration = $Folder.GetDetailsOf($File, 27)
[PSCustomObject]@{
Name = $.Name
Size = "$([int]($
.length / 1mb)) MB"
Duration = $Duration
}
} | Export-Csv -Path "./temp.csv" -NoTypeInformation

$Directory = "D:\My Source Folder"
$Shell = New-Object -ComObject Shell.Application
Get-ChildItem -Path $Directory -Recurse -Force
ForEach {
$Folder = $Shell.Namespace($.DirectoryName)
$File = $Folder.ParseName($
.Name)
$Duration = $Folder.GetDetailsOf($File, 27)
[PSCustomObject]@{
Name = $.Name
Size = "$([int]($
.length / 1mb)) MB"
Duration = $Duration
}
}
Export-Csv -Path "./temp.csv" -NoTypeInformation

Best Answer

  • JackE
    JackE ACE Posts: 44,862 Trailblazer
    Answer ✓

    You'll probably get a much better response by posting a request like this to one of the many MSDOS, FreeDOS or PowerShell forums due to the heavy syntax and debugging loads likely to be encountered, the latter of which you've already experienced. This is not an Acer-specific issue.

    Much like Linux terminal command power users, there are probably many more active MSDOS & FreeDOS afficianados than PowerShell though Microso ft seems to have a semi-active PS1 batch file forum. Google search keywords MSDOS forums for example. They'd probably welcome the challenge of debugging a BAT file like in this thread if not already done.

    There are likely a few GUI apps already available that'll accomplish the same thing if you're more interested just getting it done than doing it from a batch file.

    Good luck.

    Jack E/NJ

Answers

  • JackE
    JackE ACE Posts: 44,862 Trailblazer
    Answer ✓

    You'll probably get a much better response by posting a request like this to one of the many MSDOS, FreeDOS or PowerShell forums due to the heavy syntax and debugging loads likely to be encountered, the latter of which you've already experienced. This is not an Acer-specific issue.

    Much like Linux terminal command power users, there are probably many more active MSDOS & FreeDOS afficianados than PowerShell though Microso ft seems to have a semi-active PS1 batch file forum. Google search keywords MSDOS forums for example. They'd probably welcome the challenge of debugging a BAT file like in this thread if not already done.

    There are likely a few GUI apps already available that'll accomplish the same thing if you're more interested just getting it done than doing it from a batch file.

    Good luck.

    Jack E/NJ