Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Lounger
    Join Date
    Dec 2009
    Posts
    30
    Thanks
    2
    Thanked 1 Time in 1 Post

    Question Any software to partially change case of file/folder name?

    When naming music files I like to have them formatted like this...

    "ARTIST - Title"

    Is there a way to change "Artist - Title" to "ARTIST - Title" without having to retype filename?

  2. #2
    WS Lounge VIP access-mdb's Avatar
    Join Date
    Dec 2009
    Location
    Oxfordshire, UK
    Posts
    1,722
    Thanks
    146
    Thanked 156 Times in 149 Posts
    Have you managed to change the name manually? I ask because Windows ignores case in filenames etc. I tried changing the case of a file without success and had to do it in two changes (I added a number to the bit I wanted to change and then was able to change it back to the name and case I wanted).

    I suspect this would have to be done with a batch file or Powershell script, there are quite a few who are experts in these on here.

  3. #3
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,172
    Thanks
    47
    Thanked 981 Times in 911 Posts
    Can you supply some sample file names and we will have a go at it.

    cheers, Paul

  4. #4
    Lounger
    Join Date
    Dec 2009
    Posts
    30
    Thanks
    2
    Thanked 1 Time in 1 Post
    Quote Originally Posted by access-mdb View Post
    Have you managed to change the name manually? I ask because Windows ignores case in filenames etc. I tried changing the case of a file without success and had to do it in two changes (I added a number to the bit I wanted to change and then was able to change it back to the name and case I wanted).

    I suspect this would have to be done with a batch file or Powershell script, there are quite a few who are experts in these on here.
    Never had any problem changing the case, yes, Windows does see it as the same filename (can even change it whilst the file is open) but always displays it the way I wrote it (unlike some 3rd party softwares which will change the case if saved through them).


    Quote Originally Posted by Paul T View Post
    Can you supply some sample file names and we will have a go at it.

    cheers, Paul
    Here's a sample list of folders I've changed from...

    Awolnation - Run (2015)
    Faith No More - Sol Invictus (2015)
    Joe Satriani - Crystal Planet (1998)
    Looper - Offgrid Offline (2015)
    Man Or Astroman - Inside The Head Of John Peel (1997)
    Peatbog Faeries - Blackhouse (2015)
    Roisin Murphy - Hairless Toys (2015)
    Steve Vai - The Ultra Zone (1999)

    To...

    AWOLNATION - Run (2015)
    FAITH NO MORE - Sol Invictus (2015)
    JOE SATRIANI - Crystal Planet (1998)
    LOOPER - Offgrid Offline (2015)
    MAN OR ASTROMAN - Inside The Head Of John Peel (1997)
    PEATBOG FAERIES - Blackhouse (2015)
    ROISIN MURPHY - Hairless Toys (2015)
    STEVE VAI - The Ultra Zone (1999)


    The best method I've found so far (especially with a lot of folders) is to generate a list of the folders (I use XYplorer for this), paste the list into a Word document, highlight all the bits I want in capitals & use Words case changing function (basically what I would ideally like in the right click menu of Explorer) & then copy & pasting each folder name one at a time from Word back into the folder name.

    Longwinded process I know but a damn sight quicker than doing them all manually (especially for a one fingered typest like myself).

    Of all the renaming software I've tried so far they will only apply case changes to the whole file/folder name, not partially as I require.

    Thank you for any insight you may give.

  5. #5
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Alrock,

    Here's a little PowerShell script that will work on the directories one level under the directory your specify as a parameter.
    PS: RenameDirsbyPattern.ps1
    Code:
    <# +-------------------------------------------+
       | Program Name: RenameDirsbyPattern.ps1     |
       | Programmed by: ComputerMentor             |
       |           AKA: RetiredGeek (WSL)          |
       | Created      : 07/31/2015                 |
       | Last Update  :                            |
       | Version No.  : 1.0                        |
       +-------------------------------------------+
    #>
    Param (
           [Parameter(Mandatory=$true)]
           [string] $SourceDrivePath 
          )
    
    #Clear-Host
    
    If (Test-Path "$SourceDrivePath") {
      ForEach ($Dir in Get-ChildItem -Directory "$SourceDrivePath\" `
                -Attributes "D") {
        If ($Dir.BaseName.indexof('-') -ge 0) {
          $x = $Dir.BaseName.IndexOf('-')
          $temp = $Dir.BaseName.substring(0,$x-1)
          $NewBaseName = "$($temp.ToUpper()) $($Dir.BaseName.substring($x))"
          Rename-Item -Path "$SourceDrivePath\$Dir"`
                      -NewName "-$NewBaseName" -Force
          Rename-Item -Path "$SourceDrivePath\-$NewBaseName" `
                      -NewName "$NewBaseName" -Force
    
        } #End If($Dir.BaseName...)
    
      }   #End ForEach ($Dir...)
    }     #End If (Test-Path...)
    Else {
          Write-Host "$SourceDrivePath is not a Valid Drive:\path spec!"
          $ans = Read-Host "Press Enter to continue"
    }    #End Else
    To run open a PowerShell cmd window and type:
    d:\path\RenameDirsbyPattern.ps1 -SourceDirPath "G:\Test" {replacing G:\Test w/your drive directory.}

    Starting Data:
    RenameStartingPOS.JPG
    Ending Data:
    RenameEndingPOS.JPG
    You'll notice the two Rename-Item commands in the code. This is because PS doesn't recognize that the folder name has been changed if you only change the case! So what I did was add a - to the front of the name in the first rename then remove it with the second rename.

    If you have never run PowerShell see Post #2 Items 1-3 Here.

    BTW: You'll notice that the program did not change Test TSM as it does not have a - in the name!.

    As always when testing software on your data test on a copy first! This software has NO WARRANTY!

    HTH
    Last edited by RetiredGeek; 2015-07-31 at 22:05.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  6. #6
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Alrock,

    Here's a revised version of the Powershell that will recurse through the entire directory structure starting with the directory you specify. I tried to do this last evening but was a bit too groggy to figure it out.

    Code:
    <# +-------------------------------------------+
       | Program Name: RenameDirsbyPattern.ps1     |
       | Programmed by: ComputerMentor             |
       |           AKA: RetiredGeek (WSL)          |
       | Created      : 07/31/2015                 |
       | Last Update  :                            |
       | Version No.  : 2.0                        |
       +-------------------------------------------+
    #>
    Param (
           [Parameter(Mandatory=$True)]
           [string] $SourceDrivePath
          )
    
    #Clear-Host
    
    If (Test-Path "$SourceDrivePath") {
      ForEach ($Dir in Get-ChildItem -Directory "$SourceDrivePath\" `
                -Attributes "D" -Recurse) {
        If ($Dir.BaseName.indexof('-') -ge 0) {
          $x = $Dir.BaseName.IndexOf('-')
          $temp = $Dir.BaseName.substring(0,$x-1)
          $NewBaseName = "$($temp.ToUpper()) $($Dir.BaseName.substring($x))"
    
    
          Rename-Item -Path "$($Dir.Fullname)" `
                      -NewName "$NewBaseName-" -Force
    
          Rename-Item -Path "$($Dir.Fullname)-" `
                      -NewName "$NewBaseName" -Force
    
    
        } #End If($Dir.BaseName...)
    
      }   #End ForEach ($Dir...)
    }     #End If (Test-Path...)
    Else {
          Write-Host "$SourceDrivePath is not a Valid Drive:\path spec!"
          $ans = Read-Host "Press Enter to continue"
    }    #End Else
    You'll notice, or not, that I've moved the added hyphen from the front of the directory name to the end of the directory name. This was necessary because as the code navigates the directories I had to be able easily append, rather than stick in the middle, the - on the second Rename-Item command. I also had to capture the Dir.Fullname each time through the loop because I could no longer depend on it being the SourceDrivePath value as the code moves through the sub-directories.

    The above may or may not make sense to you but I thought I'd provide an explanation for those who may be interested.

    MusicRecurseTL.JPG
    MusicRecurseSL.JPG

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  7. #7
    WS Lounge VIP access-mdb's Avatar
    Join Date
    Dec 2009
    Location
    Oxfordshire, UK
    Posts
    1,722
    Thanks
    146
    Thanked 156 Times in 149 Posts
    I knew you'd come up with the goods RG!

  8. #8
    Lounger
    Join Date
    Dec 2009
    Posts
    30
    Thanks
    2
    Thanked 1 Time in 1 Post
    Thanks, I'll try it later & let you know how it went.

  9. #9
    4 Star Lounger
    Join Date
    Jan 2010
    Location
    Fort McMurray, Alberta, Canada
    Posts
    557
    Thanks
    51
    Thanked 68 Times in 66 Posts
    That's a slick little piece of code there RG. I've been trying to learn PS and this is helpful.

  10. #10
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Quote Originally Posted by BHarder View Post
    That's a slick little piece of code there RG. I've been trying to learn PS and this is helpful.
    B.

    Thank you...Thank you very much!

    We're in the same boat as I learning it also. Just keep on plug'n, google'n, experment'n, and of course Lounge'n as we say in the South!
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  11. #11
    Lounger
    Join Date
    Dec 2009
    Posts
    30
    Thanks
    2
    Thanked 1 Time in 1 Post
    Tried it but something went wrong somewhere...

    Copy & pasted your 1st code into notepad & renamed file to RenameDirsbyPath.ps1 as per your instructions...

    1st attempt got an error about execution of scripts being disabled, so Googled that & then tried again...

    2nd attempt...

    Code:
    Windows PowerShell
    Copyright (C) 2009 Microsoft Corporation. All rights reserved.
    
    PS C:\Windows\system32> set-executionpolicy remotesigned
    
    Execution Policy Change
    The execution policy helps protect you from scripts that you do not trust.
    Changing the execution policy might expose you to the security risks described
    in the about_Execution_Policies help topic. Do you want to change the execution
     policy?
    [Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y
    PS C:\Windows\system32> I:\RenameDirsbyPattern.ps1 -SourceDirPath "H:\MP3"
    I:\RenameDirsbyPattern.ps1 : A parameter cannot be found that matches parameter
     name 'SourceDirPath'.
    At line:1 char:42
    + I:\RenameDirsbyPattern.ps1 -SourceDirPath <<<<  "H:\MP3"
        + CategoryInfo          : InvalidArgument: (:) [RenameDirsbyPattern.ps1],
       ParameterBindingException
        + FullyQualifiedErrorId : NamedParameterNotFound,RenameDirsbyPattern.ps1
    Will try & figure out where I went wrong but since it is pretty much double dutch to me, any pointers would be handy.

  12. #12
    2 Star Lounger
    Join Date
    Dec 2009
    Location
    Tennessee,USA
    Posts
    161
    Thanks
    24
    Thanked 17 Times in 15 Posts
    If you are interested in an alternative approach and, you are familiar with Bulk Rename Utility. (BRU), you might try BRU.

    Here is an example;
    From: Applause Lady Gaga (with Vocals).cdg
    From: Applause Lady Gaga (with Vocals).mp3

    To: Lady Gaga (with Vocals).- Applause.cdg
    To: Lady Gaga (with Vocals).- Applause.mp3

    This is what you have to do in BRU.
    1. Set RegEx (1) as:
    MATCH: (.*?)-(.*)
    REPLACE: \2 - \1

    2. In the Remove (5) field, check "Trim" (that'll remove any spaces left at the beginning of the file name).

    3. Use the preview to see if everything's OK, and then press "Rename".

    See attachment for result.
    Once you get the hang of it, you have lots of power.
    Best wishes,
    Michael
    Reverse Artist Title Names with BRU.jpg

  13. #13
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Alrock,

    My bad! I typoed in the instructions!

    This: d:\path\RenameDirsbyPattern.ps1 -SourceDirPath "G:\Test"
    Should have been this: d:\path\RenameDirsbyPattern.ps1 -SourceDrivePath "G:\Test"
    Sorry! HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  14. #14
    Lounger
    Join Date
    Dec 2009
    Posts
    30
    Thanks
    2
    Thanked 1 Time in 1 Post
    Quote Originally Posted by RetiredGeek View Post
    Alrock,

    My bad! I typoed in the instructions!

    This: d:\path\RenameDirsbyPattern.ps1 -SourceDirPath "G:\Test"
    Should have been this: d:\path\RenameDirsbyPattern.ps1 -SourceDrivePath "G:\Test"
    Sorry! HTH
    Still not working for me... However, refusing to be beat I returned to my usual Renaming software fueled with a renewed determination to figure out just how to do it... Finally solved the puzzle, steps below for anybody interested...









  15. #15
    Lounger
    Join Date
    Dec 2009
    Posts
    30
    Thanks
    2
    Thanked 1 Time in 1 Post




    Thanks for all the help & inspiration...

Page 1 of 2 12 LastLast

Posting Permissions

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