title: vba - looping and renaming files and folders
body: <p>I'm trying to rename a folder how has many subfolders and files inside a main folder
  the renaming is based to many values and its need to be dynamic (i'm changing films &amp; subtitles names)</p>
  
  <p>my problem is - when the folder name answer the values for the name change the macro can't find a path to continue the loop (if the folder do not answer the values then the macro works fine)</p>
  
  <p>here what I get so far:</p>
  
  <pre><code>Sub moviestest()
      Call VideoLibrary("C:\movies")
  End Sub
  
  Private Sub VideoLibrary(path As String)
      Dim fso As New Scripting.FileSystemObject
      Dim fld As folder, f As folder, fl As File
  
      Set fso = CreateObject("Scripting.FileSystemObject")
      Set fld = fso.GetFolder(path)
  
      For Each Q In Range("Qname")
          For Each fl In fld.Files
  
              myMovie = fl.Name
              extension = InStrRev(myMovie, ".")
              myNewMovie = _
                  Replace( _
                      Replace( _
                          Replace( _
                              Replace( _
                                  Left(myMovie, extension - 1), _
                              ".", " "), _
                          "-", " "), _
                      "_", " "), _
                  Q, "") &amp; _
                  Mid(myMovie, extension)
              fso.MoveFile myMovie, myNewMovie
          Next
      Next
  
  
      For Each f In fld.SubFolders
            Call VideoLibrary(f.path)
      Next
  End Sub
  </code></pre>
  
  <p>files name are looking something like this :</p>
  
  <ul>
  <li>The.something.2013.1080p.BluRay.x264.YIFY.mkv
  The.something.2013.1080p.BluRay.x264.YIFY.sub
  Zero.something.2016.1080p.BluRay.x264-[YTS.AG].avi (and many more
  names)</li>
  </ul>
  
  <p>Qname range is somethig like this : 
  (named range in excel)</p>
  
  <pre><code> bdrip
   x264
   veto
   heb
   BRRip
   XviD
   AC3
   EVO
   blaa
   1080p
   BluRay
   YIFY
  </code></pre>
  
  <p>this is my first time asking in this forum. I hope I made my question clear as possible
  any help will be appreciated</p>