Bulk MP3 extension rename .~#T0

This topic contains 9 replies, has 4 voices, and was last updated by  Jeff Taylor 2 years, 1 month ago.

  • Author
  • #37965

    Jeff Taylor

    I've got an MP3 folder that apparently got stuck in a half state for archiving with an HP product some time ago.

    So, some artists folders got renamed "~HpShadow" and then the mp3 files themselves got the extension renamed to .~#T0

    I was hoping PS could help me find and rename these. (The Folder rename isn't necessary because the album name wouldn't be known, I'd have to do after a bit of research). But since the song titles are intact, I simply need to bulk rename the extensions to "mp3" and I believe that'll be good.

    I have this so far:

    $Dir = Get-ChildItem -dir F:\MP3s -Recurse < — works $List = $Dir | where {$_.extension -eq ".~#T0"} < —- error $list | ft name < —- just wanted to see a list of the files and location ..but I'm not getting any results from my where statement. When I pipe Get-ChildItem -dir F:\MP3s -Recurse to gm I don't see Extension as a property. Moreover, I'm getting an errro about illegal character. Which one, the tilde? How can I find the files and rename them?

  • #37966

    Curtis Smith

    The problem is going to be that you are using the -dir parameter with Get-ChildItem, which tells Get-ChildItem to only return directories, not files. Directories, of course, do not have extensions.

    Gets directories (folders). 
    To get only directories, use the Directory parameter and omit the File parameter. To exclude directories, use the File parameter and omit the Directory parameter, or use the Attributes parameter.
    To get directories, use the Directory parameter, its "ad" alias, or the Directory attribute of the Attributes parameter.
  • #37971

    random commandline
    $files = Get-ChildItem -Path .\path\to\files -Filter '*.~#T0' -Recurse
    "$($files.Count) files found"
    $files.DirectoryName | Out-File .\path\to\files\parentlog.txt -Append
    $files | Rename-Item -NewName {$_.Name -replace '.~#T0','.mp3'} -whatif
  • #38000

    Jeff Taylor


    How come neither the -dir nor the -file parameters are listed in the get-help get-childItem -Full help file?


  • #38007

    Bob McCoy

    The -dir and -file switches were introduced in v3. Are you running v3 or later? Have you updated your help files?

  • #38008

    Jeff Taylor

    v4 but I can't update AD and GP modules for some reason. I do have an access denied issue open with MS on this very subject and also soliciting help from this forum: https://powershell.org/forums/topic/update-help-access-denied-on-domain-controller/

  • #38018

    Curtis Smith

    @jeff-taylor, in addition to Bob's reply, Get-ChildItem is used by much more than just a file system. It can work with other providers, such as the Registry, which does not support -directory and -file

    Here is a link to "Get-ChildItem for FileSystem"

  • #38082

    Jeff Taylor

    random commanline thanks -whatif works great. How would I measure the number of files discovered/changed?

    I tried:
    Get-ChildItem -Path F:\MP3s -Filter '*.~#T0' -Recurse | Rename-Item -NewName {$_.Name -replace '.~#T0','.mp3'} -WhatIf | measure

    returns value = 0

    ...and also, how can I log the returned parent folders which contain these files? I'll have to change the name from ~HPShadow to the album name after some analysis.

    thanks again

  • #38093

    random commandline

    Try it again. I modified my script to display number of files found and output parent folders to a log file.

  • #38137

    Jeff Taylor

    random commandline Thanks a lot..Worked a charm and I learned a lot in the process...Cheers

You must be logged in to reply to this topic.