title
Products            Buy            Support Forum            Professional            About            Codec Central
 

File Name Restricted Characters -- Remove instead of Replace

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • koffeetalk

    • May 2009
    • 12

    File Name Restricted Characters -- Remove instead of Replace

    In both the CD Ripper and the Batch Converter, I would prefer to remove illegal characters like the question mark from the file name. I do not want the upside down question mark in the file name. Is there a way to do this? I'm using dBpoweramp 14.2.

    I don't want to use the Character / Word Replacement setting, because I want these characters available for the song title tag.

    Is there a way to strip out the illegal characters when creating the file name? I can't seem to do this with the File Name Restricted Characters options.

    Thanks.
  • dbfan
    dBpoweramp Guru

    • Jan 2011
    • 937

    #2
    Re: File Name Restricted Characters -- Remove instead of Replace

    I do not think you can.

    Comment

    • dizwell

      • Feb 2007
      • 27

      #3
      Re: File Name Restricted Characters -- Remove instead of Replace

      I realise this is a very old thread, but since I ran into exactly the same problem this morning, here's my suggested solution:

      Create a vbs script file containing the following code (I saved mine using the filename "removechars.vbs":

      Code:
      Set fso = CreateObject("Scripting.FileSystemObject")
      Set re  = New RegExp
      
      re.Pattern =  "[¿]" ' you can add other characters you want stripped between those two brackets, too'
      re.IgnoreCase = True
      re.Global = True
      
      If WScript.Arguments.Unnamed.Count = 1 Then
        If fso.FolderExists(WScript.Arguments.Unnamed(0)) Then
          Recurse fso.GetFolder(WScript.Arguments.Unnamed(0))
        Else
          WScript.Echo "Folder not found."
        End If
      Else
        WScript.Echo "Please give folder name as argument 1."
      End If
      
      
      Sub Recurse(f)
        For Each sf In f.SubFolders
          Recurse sf
           If re.Test(sf.Name) Then       
             WScript.Echo sf.Name, " -> ", re.Replace(sf.Name, "")
             sf.Name = re.Replace(sf.Name, "")
           End If
        Next
        For Each sf In f.Files
           If re.Test(sf.Name) Then
             WScript.Echo sf.Name, " -> ", re.Replace(sf.Name, "")
             sf.Name = re.Replace(sf.Name, "") 
          End If
        Next
      End Sub
      Invoke the script like so:

      Code:
      cscript removechars.vbs "c:\path\to\where\ripped\files\are\stored"
      Here's one example of me running it:

      Code:
      C:\Users\Administrator\Desktop>cscript removechars.vbs "C:\Users\Administrator\Music\Benjamin Britten\Peter Grimes (CW)"
      Microsoft (R) Windows Script Host Version 5.8
      Copyright (C) Microsoft Corporation. All rights reserved.
      
      16 - Have you heard¿ The cliff is down.wma  ->  16 - Have you heard The cliff is down.wma
      25 - What is it¿.wma  ->  25 - What is it.wma
      28 - Swallow! Shall we go and see Grimes in his hut¿.wma  ->  28 - Swallow! Shall we go and see Grimes in his hut.wma
      30 - From the gutter, why should we trouble at their ribaldries¿.wma  ->  30 - From the gutter, why should we trouble at their ribaldries.wma
      34 - Peter Grimes! Nobody here¿.wma  ->  34 - Peter Grimes! Nobody here.wma
      ...and you can see that the troublesome inverted question mark has been stripped from the file names that needed the treatment.
      Last edited by dizwell; July 19, 2013, 10:52 PM.

      Comment

      • Porcus
        dBpoweramp Guru

        • Feb 2007
        • 792

        #4
        Re: File Name Restricted Characters -- Remove instead of Replace

        Find one legal character you can do without (with Unicode, that shouldn't be too much of a problem?)
        Use http://www.bulkrenameutility.co.uk/

        Comment

        • dizwell

          • Feb 2007
          • 27

          #5
          Re: File Name Restricted Characters -- Remove instead of Replace

          Yes, there are programs available to do most things, but your suggestion looks like a classic case of "sledgehammer meet nut" to me.

          The OP (and me!) have a simple, tightly-defined requirement: to strip one or two characters from a file name immediately after it has been ripped. So, of course bulk file-renaming utilities like the one you mention could do that -and if I'd already installed something like that for other reasons, that would be the tool I'd look to use. But the beauty of a little VBS script such as the one I posted is that it can be called, entirely self-contained, after every rip by adding its details into the 'Run External' DSP plugin, like so:



          It's a self-contained solution that does only what's asked of it, and no more... and the learning curve is happily flat (provided someone has written the script for you, of course! Which in this case, they have).
          Last edited by dizwell; July 27, 2013, 07:33 AM.

          Comment

          Working...

          ]]>