My VBscript processed the same 20 files in 0.6 seconds. As before, try it out on test files/folders first!!! Place as a .vbs file in the top folder (like the .bat) and you can double click it in Windows Explorer. You should not see a console window, just 2 message boxes.
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
set objShell = createobject("wscript.shell")
strScriptDir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
iInfoCount = 0
For Each objFolder In objFSO.GetFolder(strScriptDir).SubFolders
aFilePath = split(objFolder.Path, "\")
strSubFolderName = aFilePath(Ubound(aFilePath))
strNFOpath = objFolder.Path & "\" & "movie.nfo"
If objFSO.FileExists(strNFOpath) Then
iInfoCount = iInfoCount + 1
End If
Next
v = msgbox("Found " & iInfoCount & " movie.nfo file(s)" & vbcrlf & vbcrlf & "Click OK to start or Cancel to quit", 1, "Movie.nfo processor")
if v = 2 Then
wscript.quit
End If
st = timer
iFiles = 0
For Each objFolder In objFSO.GetFolder(strScriptDir).SubFolders
aFilePath = split(objFolder.Path, "\")
strSubFolderName = aFilePath(Ubound(aFilePath))
strNFOpath = objFolder.Path & "\" & "movie.nfo"
If objFSO.FileExists(strNFOpath) Then
set nfoFile = objFSO.OpenTextFile(strNFOpath, 1)
content = nfoFile.ReadAll
aNFOfileLines = split(content, vbcrlf)
For iLine = 0 To Ubound(aNFOfileLines)
strThisLine = aNFOfileLines(iLine)
If instr(strThisLine, "<title>") > 0 Then
If instr(strThisLine, "</title>") > 0 Then
strLineIndent = Space(instr(strThisLine, "<title>")-1)
strOldLine = strThisLine
strNewLine = "<title>" & strSubFolderName & "</title>"
aNFOfileLines(iLine) = strLineIndent & strNewLine
Exit For
End If
End If
Next
nfoFile.close
objShell.currentdirectory = objFolder
Set objTextFile = objFSO.OpenTextFile ("movie.nfo.new", ForWriting, True)
For iLine = 0 To Ubound(aNFOfileLines)
objTextFile.WriteLine(aNFOfileLines(iLine))
Next
objTextFile.Close
objFSO.DeleteFile "movie.nfo"
objFso.MoveFile "movie.nfo.new", "movie.nfo"
objShell.currentdirectory = strScriptDir
iFiles = iFiles + 1
End If
Next
et = timer
strMsg = "Processed " & iFiles & " file(s)" & vbcrlf & vbcrlf & "in " & et-st & " seconds"
v = msgbox(strMsg, 0, "Movie.nfo processor")