Results 1 to 10 of 10
  1. #1
    New Lounger
    Join Date
    Dec 2009
    Location
    New Jersey
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Various PowerShell questions and extended file properties

    Win 7 64 bit.

    I am trying to obtain the length of mp3 and mov files using extended file properties. I created a nasty, but working way using VBS but thought I'd give PowerShell a try and found an example to modify.

    It gives me the correct answer SOMETIMES as I test with various files, but sometimes NOT. It is driving me crazy. For a correct answer, I'm using the Length value I can display in Windows Explorer.

    I also realize I must divide length by some value to convert to seconds, but I have to keep changing this value for various files to get the correct answer. 16000 works for one mp3 file, but not another in the same folder. What should be 02:22 comes back as 02:58 for one and 01:00 and 01:01 (which is fine) for another. What the heck am I doing wrong?

    Finally, I have four versions of PS in my start menu.... PS (x86), PS ISE, PS, and PS (x86) ISE. What's the difference?

    "C:\Windows\syswow64\Windowspowershell\v1.0\powers hell.exe" -noexit dir "D:\Audio\Songs\OtherSongs\Theme 1.mp3" | Select-object @{Expression={ '{0:#,00.00}' -f ($_.length/16000)};Label="Playing time"}

    Thanks for any help in any of this.

  2. #2
    Platinum Lounger
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    3,846
    Thanks
    7
    Thanked 253 Times in 238 Posts
    MP3 files are compressed and the size is related to the amount of music info. Straight division won't give you an accurate answer.
    5 minute of a single guitar will produce a small file.
    5 minutes of a symphony orchestra will produce a large file.

    cheers, Paul

  3. #3
    New Lounger
    Join Date
    Dec 2009
    Location
    New Jersey
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I understand what you are saying and it works correctly when I use objFolder.GetDetailsOf(strFileItem, 27) in vbs.

    PowerShell must have a way to access the information. Does anyone know how?

  4. #4
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    20,656
    Thanks
    2
    Thanked 635 Times in 568 Posts
    See if Read extend file attributes helps.

    Joe

  5. #5
    5 Star Lounger
    Join Date
    Jan 2010
    Location
    Los Angeles, CA
    Posts
    798
    Thanks
    3
    Thanked 28 Times in 26 Posts
    I use TagLib-Sharp (https://github.com/mono/taglib-sharp) for reading MP3 tags. I have been using it with PowerShell for years to manage my MP3 collection. I have all my MP3s organized in a separate folder (not referenced via my music library or anything else) and I use a PowerShell script with taglib-sharp to copy randomly selected MP3s (based on rating and maximum target directory size) to other folders, which I then use to play music in winamp or copy to my MP3 player or to other devices. Part of the report I print at the end is how many hours/minutes/seconds of music I copied.

    I recently have a need to read video data also (mainly the length of the video), and will try using taglig-sharp for that also. I should know in a month or so how that went.

    There are several tutorials on using taglib-sharp. But if interested I could post some code snippets.

  6. #6
    New Lounger
    Join Date
    Dec 2009
    Location
    Gillingham, Dorset, UK
    Posts
    15
    Thanks
    0
    Thanked 8 Times in 7 Posts
    To answer your other question, Windows Powershell (x86) is the 32-bit, and Windows Powershell is the 64-bit console version. Similarly, Windows Powershell (x86) ISE is the 32-bit, and Windows Powershell ISE is the 64-bit Integrated Scripting Environment version.

  7. The Following User Says Thank You to Cliff.H For This Useful Post:

    wmfay1 (2012-04-11)

  8. #7
    New Lounger
    Join Date
    Dec 2009
    Location
    New Jersey
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for your reply and offer. I REALLY want to spend time getting familiar with PowerShell but know nothing about it at this time so TagLib-Sharp seems way over my head for now.

    I was hoping for a one line command I could enter with a hard coded mp3 filename which would return the song duration which I can direct into my program and parse and use. I didn't think this would be such a difficult request but it seems I have a talent for asking the simple questions which are not. I do have a way to get the duration using VBS so, unless some PS expert posts the code, I'm stuck for now.

    I don't even know how to run a PS 'batch' file yet but it is on my list!

  9. #8
    New Lounger
    Join Date
    Dec 2009
    Location
    New Jersey
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Cliff.H View Post
    To answer your other question, Windows Powershell (x86) is the 32-bit, and Windows Powershell is the 64-bit console version. Similarly, Windows Powershell (x86) ISE is the 32-bit, and Windows Powershell ISE is the 64-bit Integrated Scripting Environment version.
    Thanks for the info. I still don't know when to use the console and when to use the ISE, but at least I know the difference and can look it up. I appreciate it.

  10. #9
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,503
    Thanks
    212
    Thanked 853 Times in 785 Posts
    TTTWSL,

    In a nutshell, use the ISE to develope & debug and the console to run your debugged code.
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  11. The Following User Says Thank You to RetiredGeek For This Useful Post:

    Kuan (2013-01-10)

  12. #10
    New Lounger
    Join Date
    Jan 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Various PowerShell questions and extended file properties

    hello

    use this stuf:


    # $music = [system.Environment]::GetFolderPath("............")
    $list = dir "..... folder name ....." -Recurse | Add-FileDetails
    $list | Where-Object { $_.Extended_length} | Sort-Object Extended_length | Select-Object Name, Extended_length
    $list

    greats
    @renas

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •