To
- retrieve all PDF-files in Directory G:\OF and its subdirectories
- to merge all pdf-files in every subdirectory into 1 merged PDF-file
- to store the merged files into a directory that is not Directory G:\OF or one of its subdirectories:


Sub M_snb()
    sn = Split(CreateObject("wscript.shell").exec("cmd /c dir ""G:\OF\*.pdf"" /b/s").stdout.readall, vbCrLf)
    
    For j = 1 To UBound(sn) - 1
       c00 = Left(sn(j), Len(sn(j)) - Len(Dir(sn(j))))
       If InStr(c01, vbLf & c00) = 0 Then c01 = c01 & vbLf & c00
    Next
    
    If c01 <> "" Then
       sp = Split(Mid(c01, 2), vbLf)
       For Each it In sp
          M_MergePDF Filter(sn, it), "G:\merged_" & Replace(it, "\", "_") & "pdf"
       Next
    End If
End Sub
Sub M_MergePDF(sn, c00)
  With CreateObject("AcroExch.PDDoc").Open(sn(0))
    For j = 1 To UBound(sn)
      Set pdf = CreateObject("AcroExch.PDDoc").Open(sn(j))
      .InsertPages .GetNumPages - 1, pdf, 0, pdf.GetNumPages, 0
      pdf.Close
    Next

    .Save 1, c00
    .Close
  End With

  Set pdf = Nothing
End Sub