+ Reply to Thread
Results 1 to 32 of 32

Remove Suffix From Files

Hybrid View

  1. #1
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Remove Suffix From Files

    Hello Orangeworker,

    Unfortunately, colors are not rendered in the code window. You will need to bold the lines or add comments so I know which to look at.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  2. #2
    Registered User
    Join Date
    03-04-2010
    Location
    South Florida
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Remove Suffix From Files

    Sorry about that. The bold text is turning yellow when I run the code with the break points.

    Sub RenameFiles()
    
      Dim FileName As String
      Dim FilePath As String
      Dim NewFileName As String
      Dim RegExp As Object
      Dim vFolder As Variant
      
        Set RegExp = CreateObject("VBScript.RegExp")
        RegExp.IgnoreCase = True
        RegExp.Pattern = "(.+)(O\-.+)(\..*)"
            
        FilePath = "D:\Publishing\Catalog\"
        
        RegExp.test (FileName)
        NewFileName = RegExp.Replace(FileName, "$1$3")
        
        
         For Each vFolder In Array("Vox", "Ins")
            FileName = Dir(FilePath & vFolder & "\*.*")
              While FileName <> ""
                If RegExp.test(FileName) Then
                   NewFileName = RegExp.Replace(FileName, "$1$3")
                   Name FilePath & vFolder & FileName As FilePath & vFolder & NewFileName
                End If
                FileName = Dir()
              Wend
          Next vFolder
        
    End Sub

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Remove Suffix From Files

    Hello Orangeworker,

    Did you change the file path? The PDF shows yet another path??? Which am I to believe?
      'Originally
       FilePath = "E:\Publishing\Catalog\"
    
    
      'PDF Path
       FilePath = "D:\Publishing\Catalog\Alexander\"

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Remove Suffix From Files

    Hello Orangeworker,

    How many break points to add? You only needed to add one where I specified to check if the file path and name were correct. What values did you see?

  5. #5
    Registered User
    Join Date
    03-04-2010
    Location
    South Florida
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Remove Suffix From Files

    Okay, this is where we're going wrong. The path listed in the PDF is correct. "Alexander" is an artist, but their are many different artist names (folders) in that section of the directory. Does that clear it up?

      'PDF Path
       FilePath = "D:\Publishing\Catalog\Alexander\"

  6. #6
    Registered User
    Join Date
    03-04-2010
    Location
    South Florida
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Remove Suffix From Files

    The values listed below are what I'm getting when inserting the break point on
    Name FilePath & vFolder & FileName As FilePath & vFolder & NewFileName

    FilePath="D:\Publishing\Catalog\Alexander\"
    FileName="Be Careful What You Wish For O-0007.wav"
    vFolder= "Vox"

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Remove Suffix From Files

    Hello Orangeworker,

    I am still clear on on how you have these directories setup. If you various folders based on the artists names in the main path "D:\Publishing\Catalog\" then there needs to extra step in the macro to open these artists' folders, unless you are looking only in the folders "Vox" and "Ins".

    My question is then which path should the macro be using: "D:\Publishing\Catalog\Alexander\Vox" or "D:\Publishing\Catalog\Vox" ? If artist needs to included then I will need to change the macro.

  8. #8
    Registered User
    Join Date
    03-04-2010
    Location
    South Florida
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Remove Suffix From Files

    Hi Leith,

    Sorry for the miscommunication. What I can do is just list all the file paths for all of my artists. Would the example below work?

    FilePath = "D:\Publishing\Catalog\Alexander\Ins\"
    FilePath = "D:\Publishing\Catalog\Alexander\Vox\"

    And so on for the other artists..

    But with that said, this path still doesn't remove O-*

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1