Off topic renaming help.

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #392185

    So I’ve been stumped on something for a little while, and I figured it couldn’t hurt to ask here.

     

    Have we heard of Pop’nMusic? Stepmania? Maybe? Cool.

     

    Stepmania doesn’t support UTF-8 Characters in file or folder names when loading songs. It sucks, because I have a dump of Pop’N Music songs that I’d like to play, but none of them will load in Stepmania due to them looking like this: Song Folder

    Inside Song Folder

     

    (Sorry, have to link to picture due to the width of it. Is it possible to resize pictures with BBcode on this forum?)

     

    I’m looking for a way to rename these folders and files, without manually doing 1000s of files one by one. I’m just looking to rename things with Underscores or dashes, just so that it’s read by Stepmania on loading. I don’t really care about preserving the filenames in the least bit.

     

     

    If this is too off topic, it can be removed. No real place to post this here.

     

    Thanks for looking!

    #444108
    Farottone
    Keymaster

      Have you looked for batch renaming utilities?

      #444109

      I have. currently messing around with Ken Rename, although it’s not going so well. It works maybe half the time if I convert Unicode to Windows 1250, but then breaks a ton of files in the process. Have any suggestions on other renaming utilities?

      #444110
      Farottone
      Keymaster

        I use this one but it’s not free and I don’t know if it fits your needs:

         

        http://www.publicspace.net/windows/BetterFileRename/

        #444114

        Interestingly enough, I just solved my problem by switching windows to Japanese locale.

         

        Not exactly the way I wanted to go about it, but I suppose it works.

         

         

        Thanks anyway

        #444150
        espher
        Participant

          If you’ve got Powershell, you could try this. I haven’t tested it on my machine as I don’t have any files that fit (and I was looking to spin up a Japanese region WinXP or Win7 VM for some other project work but have yet to get around to it sooo).

           

          I recommend opening the PowerShell ISE (C:WindowsSystem32WindowsPowerShellv1.0powershell_ise.exe), creating a new script, pasting this in, replacing the $folderPath variable with the root folder where your files are located, and hitting Run Script (the play button):

           


          $folderPath = "your folder path here"
          $filesArray = Get-ChildItem -Path $folderPath -Recurse | Where {$_.Name -Match "[^U0020-U007F]"}
          $filesArray | ForEach-Object {
          $newFileName = [Text.Encoding]::ASCII.GetString([Text.Encoding]::GetEncoding("Shift-JIS").GetBytes($_.Name))
          $newFileName = $newFileName.Replace('?','_')
          If ($_.Name -ne $newFileName) {
          $increm = 1
          $testName = $_.FullName.Replace($_.Name,$newFileName)
          While (Test-Path -Path $testName)
          {
          $nextName = ([iO.FileInfo]$newFileName).BaseName + "_($num)" + ([iO.FileInfo]$newFileName).Extension
          $testName = $_.FullName.Replace($_.Name,$nextName)
          $num += 1
          }
          ren $_.FullName $testName
          }
          }

           

          I recommend trying it with a folder with 1-2 copied songs or w/e as a test in case I break all of the things.

           

          Basically, what it should do is this:

           

          * Build an array with a list of every file and folder (and subfolders), starting in a designated base folder, that have non-ASCII characters.

          * Take each name and make it into an ASCII string (this will change all of the non-ASCII characters to ?). I am assuming (perhaps incorrectly) that the filenames are in Shift-JIS encoding.

          * Converts every ? in the string to a _.

          * Renames the file to a matching one and avoids a conflict by appending a number at the end in a case where you’d get two identical files.

           

          Edit: If you’re cool with Japanese non-unicode, though, that might work best. <img decoding=” src=”/wp-content/uploads/invision_emoticons/default_SA_smile.gif”>

          #444156


          PS C:UsersAtom> $folderPath = "C:/Test Script"
          $filesArray = Get-ChildItem -Path $folderPath -Recurse | Where {$_.Name -Match "[^U0020-U007F]"}
          $filesArray | ForEach-Object {
          $newFileName = [Text.Encoding]::ASCII.GetString([Text.Encoding]::GetEncoding("Shift-JIS").GetBytes($_.Name))
          $newFileName = $newFileName.Replace('?','_')
          If ($_.Name -ne $newFileName) {
          $increm = 1
          $testName = $_.FullName.Replace($_.Name,$newFileName)
          While (Test-Path -Path $testName)
          {
          $nextName = ([iO.FileInfo]$newFileName).BaseName + "_($num)" + ([iO.FileInfo]$newFileName).Extension
          $testName = $_.FullName.Replace($_.Name,$nextName)
          $num += 1
          }
          ren $_.FullName $testName
          }
          }
          Bad argument to operator '-match': parsing "[^U0020-U007F]" - Unrecognized escape sequ
          ence U..
          At line:2 char:79
          + $filesArray = Get-ChildItem -Path $folderPath -Recurse | Where {$_.Name -Match <<<< "
          [^U0020-U007F]"}
          + CategoryInfo : InvalidOperation: ( [], RuntimeException
          + FullyQualifiedErrorId : BadOperatorArgument

          -At this point, it output this a couple hundred times SNIP-

          Bad argument to operator '-match': parsing "[^U0020-U007F]" - Unrecognized escape sequence U..
          At line:2 char:79
          + $filesArray = Get-ChildItem -Path $folderPath -Recurse | Where {$_.Name -Match <<<< "[^U0020-U007F]"}
          + CategoryInfo : InvalidOperation: ( [], RuntimeException
          + FullyQualifiedErrorId : BadOperatorArgument

          Exception calling "GetBytes" with "1" argument(s): "Array cannot be null.
          Parameter name: chars"
          At line:4 char:103
          + $newFileName = [Text.Encoding]::ASCII.GetString([Text.Encoding]::GetEncoding("Shift-JIS").GetBytes <<<< ($_.
          Name))
          + CategoryInfo : NotSpecified: ( [], MethodInvocationException
          + FullyQualifiedErrorId : DotNetMethodException

          You cannot call a method on a null-valued expression.
          At line:5 char:40
          + $newFileName = $newFileName.Replace <<<< ('?','_')
          + CategoryInfo : InvalidOperation: (Replace:String) [], RuntimeException
          + FullyQualifiedErrorId : InvokeMethodOnNull


          ____________________________________________________

           

           

           

          I need to learn to powershell. I recently started a video series on it actually.

          Don’t kill yourself with this, and thanks a lot for the help :]

          #444158
          espher
          Participant

            Sorry, I think:

             

            [^U0020-U007F]

             

            should be

             

            [^u0020-u007F]

             

            I forgot it needs to be lowercase. I’m not a regex-y guy. <img decoding=” src=”/wp-content/uploads/invision_emoticons/default_SA_emot-3.gif”>

             

            I’d also make sure the path has a instead of a /.

            #444176

            Mmm, good call on the path, I guess this is Windows. haha

             

            I’ll give it a go.

             

            EDIT: When I copied it into the ISE, it must have converted it to lowercase when I ran it, because it’s already lowercase.

             

            EDIT 2: I’m actually just incredibly blind, it was still uppercase. Now it’s lowercase. Now it spit out this:

             

            PS C:UsersAtom> $folderPath = "C:Test Script"
            $filesArray = Get-ChildItem -Path $folderPath -Recurse | Where {$_.Name -Match '[^u0020-u007F]'}
            $filesArray | ForEach-Object {
            $newFileName = [Text.Encoding]::ASCII.GetString([Text.Encoding]::GetEncoding("Shift-JIS").GetBytes($_.Name))
            $newFileName = $newFileName.Replace('?','_')
            If ($_.Name -ne $newFileName) {
            $increm = 1
            $testName = $_.FullName.Replace($_.Name,$newFileName)
            While (Test-Path -Path $testName)
            {
            $nextName = ([iO.FileInfo]$newFileName).BaseName + "_($num)" + ([iO.FileInfo]$newFileName).Extension
            $testName = $_.FullName.Replace($_.Name,$nextName)
            $num += 1
            }
            ren $_.FullName $testName
            }
            }
            Test-Path : Cannot retrieve the dynamic parameters for the cmdlet. The specified wildcard pattern is not valid: _A
            ___p___}__ - _A___p___}_____}_[_
            At line:9 char:25
            + While (Test-Path <<<< -Path $testName)
            + CategoryInfo : InvalidArgument: ( [Test-Path], ParameterBindingException
            + FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.TestPathCommand

            Rename-Item : Cannot rename because the target specified represents a path or device name.
            At line:15 char:12
            + ren <<<< $_.FullName $testName
            + CategoryInfo : InvalidArgument: ( [Rename-Item], PSArgumentException
            + FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.RenameItemCommand

            Test-Path : Cannot retrieve the dynamic parameters for the cmdlet. The specified wildcard pattern is not valid: _G
            _[_Q - ____________G_[_Q_C___e_[_}_
            At line:9 char:25
            + While (Test-Path <<<< -Path $testName)
            + CategoryInfo : InvalidArgument: ( [Test-Path], ParameterBindingException
            + FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.TestPathCommand

            Test-Path : Cannot retrieve the dynamic parameters for the cmdlet. The specified wildcard pattern is not valid: _
            _D_h_D____________ - _R___s___[_^_[____________
            At line:9 char:25
            + While (Test-Path <<<< -Path $testName)
            + CategoryInfo : InvalidArgument: ( [Test-Path], ParameterBindingException
            + FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.TestPathCommand

            Rename-Item : Cannot rename because item at 'C:Test Scriptアメリカ - STAR TREKアメリカ [5button]_100.bme' does not exis
            t.
            At line:15 char:12
            + ren <<<< $_.FullName $testName
            + CategoryInfo : InvalidOperation: ( [Rename-Item], PSInvalidOperationException
            + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand

            Rename-Item : Cannot rename because item at 'C:Test Scriptアメリカ - STAR TREKアメリカ [5button]_100.pms' does not exis
            t.
            At line:15 char:12
            + ren <<<< $_.FullName $testName
            + CategoryInfo : InvalidOperation: ( [Rename-Item], PSInvalidOperationException
            + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand

            Rename-Item : Cannot rename because item at 'C:Test Scriptアメリカ - STAR TREKアメリカ [bATTLE]_253.bme' does not exist
            .
            At line:15 char:12
            + ren <<<< $_.FullName $testName
            + CategoryInfo : InvalidOperation: ( [Rename-Item], PSInvalidOperationException
            + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand

            Rename-Item : Cannot rename because item at 'C:Test Scriptアメリカ - STAR TREKアメリカ [bATTLE]_253.pms' does not exist
            .
            At line:15 char:12
            + ren <<<< $_.FullName $testName
            + CategoryInfo : InvalidOperation: ( [Rename-Item], PSInvalidOperationException
            + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand

            Rename-Item : Cannot rename because item at 'C:Test Scriptアメリカ - STAR TREKアメリカ [HYPER]_259.bme' does not exist.
            At line:15 char:12
            + ren <<<< $_.FullName $testName
            + CategoryInfo : InvalidOperation: ( [Rename-Item], PSInvalidOperationException
            + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand

            Rename-Item : Cannot rename because item at 'C:Test Scriptアメリカ - STAR TREKアメリカ [HYPER]_259.pms' does not exist.
            At line:15 char:12
            + ren <<<< $_.FullName $testName
            + CategoryInfo : InvalidOperation: ( [Rename-Item], PSInvalidOperationException
            + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand




            -SNIP Couple thousand lines Does not exist at this point. SNIP-



            Rename-Item : Cannot rename because item at 'C:Test ScriptA.I.ãŠã°ã‚ã¡ã‚ƒã‚“ - コンピューターãŠã°ã‚ã¡ã‚ƒã‚“A.I.ãŠã°ã‚ã¡ã‚ƒã‚“ [x5button]_120.p
            ms' does not exist.
            At line:15 char:12
            + ren <<<< $_.FullName $testName
            + CategoryInfo : InvalidOperation: ( [Rename-Item], PSInvalidOperationException
            + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand

            Rename-Item : Cannot rename because item at 'C:Test ScriptA.I.ãŠã°ã‚ã¡ã‚ƒã‚“ - コンピューターãŠã°ã‚ã¡ã‚ƒã‚“A.I.ãŠã°ã‚ã¡ã‚ƒã‚“ [xNORMAL]_165.bm
            e' does not exist.
            At line:15 char:12
            + ren <<<< $_.FullName $testName
            + CategoryInfo : InvalidOperation: ( [Rename-Item], PSInvalidOperationException
            + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand

            Rename-Item : Cannot rename because item at 'C:Test ScriptA.I.ãŠã°ã‚ã¡ã‚ƒã‚“ - コンピューターãŠã°ã‚ã¡ã‚ƒã‚“A.I.ãŠã°ã‚ã¡ã‚ƒã‚“ [xNORMAL]_165.pm
            s' does not exist.
            At line:15 char:12
            + ren <<<< $_.FullName $testName
            + CategoryInfo : InvalidOperation: ( [Rename-Item], PSInvalidOperationException
            + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand

            Rename-Item : Cannot rename because item at 'C:Test ScriptA.I.ãŠã°ã‚ã¡ã‚ƒã‚“ - コンピューターãŠã°ã‚ã¡ã‚ƒã‚“A.I.ãŠã°ã‚ã¡ã‚ƒã‚“.lr' does not exi
            st.
            At line:15 char:12
            + ren <<<< $_.FullName $testName
            + CategoryInfo : InvalidOperation: ( [Rename-Item], PSInvalidOperationException
            + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand


            _______________________________________________________________________________________________________________

             

             

             

            EDIT 3: This is probably really obvious, but I’ll say it anyway. It looks like It’s renaming the folders before the files inside, and that’s making the path change so It can’t find the files it would like to rename afterwards.

            #444247
            espher
            Participant

              Alright, that’s probably a quick fix. I’ll take a look tonight. I likely need to have it iterate through all the files first and then go for folders as a separate loop.

               

              In theory, running it twice in a row ‘should’ work, as the first time it should get folders and then the second time it should not have to rename folders and then get the files inside…

               

              Maybe I’ll try to create some files to test it with on my machine.

              #444271

              It’s not a big deal, don’t put any significant amount of time to it.

              I can zip up some files and send them your way if you’d like as well.

              #444303
              TomGuy
              Participant
                So I’ve been stumped on something for a little while, and I figured it couldn’t hurt to ask here.

                 

                Have we heard of Pop’nMusic? Stepmania? Maybe? Cool.

                 

                I saw StepMania and I got excited. Didn’t know anyone else actually played it besides me, ha ha.

                #444348
                So I’ve been stumped on something for a little while, and I figured it couldn’t hurt to ask here.

                 

                Have we heard of Pop’nMusic? Stepmania? Maybe? Cool.

                 

                I saw StepMania and I got excited. Didn’t know anyone else actually played it besides me, ha ha.

                 

                Yeah. I’ve been playing stepmania on and off for like 10 years. It’s relaxing. I’m making a song at the moment.

                #444352
                espher
                Participant
                  It’s not a big deal, don’t put any significant amount of time to it.

                  I can zip up some files and send them your way if you’d like as well.

                   

                  Sure.

                  #444437

                  Woops, thought I posted the link. Big download. cool stuff the way these files work.

                   

                  http://www.mediafire.com/download/fnoo6 … nicode.rar

                Viewing 15 posts - 1 through 15 (of 19 total)
                • You must be logged in to reply to this topic.
                Back to top button