Skip to content

Instantly share code, notes, and snippets.

@dnas2
Created July 22, 2016 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnas2/9c632ef6468d5cef33464b57914d3c86 to your computer and use it in GitHub Desktop.
Save dnas2/9c632ef6468d5cef33464b57914d3c86 to your computer and use it in GitHub Desktop.
Powershell for exporting CSV of MP3 tracks in directory with length
$resultsarray = @()
$shell = New-Object -COMObject Shell.Application
Get-ChildItem "[PATH HERE]" |
Foreach-Object {
$linkObject = new-object PSObject
$path = $_.FullName
$folder = Split-Path $path
$file = Split-Path $path -Leaf
$shellfolder = $shell.Namespace($folder)
$shellfile = $shellfolder.ParseName($file)
linkObject | add-member -membertype NoteProperty -name "File" -Value $file
linkObject | add-member -membertype NoteProperty -name "Length" -Value $shellfolder.GetDetailsOf($shellfile, 27)
$resultsarray += $linkObject
write-host """$($file)"", $($shellfolder.GetDetailsOf($shellfile, 27))";
}
$resultsarray| Export-csv export.csv -notypeinformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment