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 & subtitles names)
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)
here what I get so far:
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, "") & _
Mid(myMovie, extension)
fso.MoveFile myMovie, myNewMovie
Next
Next
For Each f In fld.SubFolders
Call VideoLibrary(f.path)
Next
End Sub
files name are looking something like this :
- 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)
Qname range is somethig like this : (named range in excel)
bdrip
x264
veto
heb
BRRip
XviD
AC3
EVO
blaa
1080p
BluRay
YIFY
this is my first time asking in this forum. I hope I made my question clear as possible any help will be appreciated
The best approach is make a function that will return the new name. This will also make the code easier to read, modify and debug.