I'll post the code here, as well as send the sample to you. The code makes the following assumptions:
You have the batch file "Direct.bat" in the "C:\batch55" directory. Direct.bat has only one line:
Dir > Direct.txt
All the subfolders that are created are named
"Batchxxx" where the "xxx" is replaced by a number.
This worked fine on my system (access 97 / Windows XP). Different versions of windows may display the directory differently. I think this will work with others, too, but I'm not sure. If it won't, let me know.
I just put this code in the On Click event of a command button:
Private Sub Command0_Click()
On Error GoTo ErrHandler
Dim RetVal
RetVal = Shell("C:\batch55\direct.bat"

Open "C:\batch55\direct.txt" For Input As #1
Open "C:\batch55\Direct2.txt" For Output As #2
Dim Hold As String
Dim Locate As Integer
Do Until EOF(1)
Line Input #1, Hold
If InStr(1, Hold, "<DIR>", 1) > 5 Then 'finds directories
Print #2, Hold
End If
Loop
Close #1
Close #2
Dim DirName As String
Dim DirName2 As String
Dim FName1 As String
Dim FName2 As String
DirName = "C:\batch55\"
Open "C:\batch55\Direct2.txt" For Input As #1
Do Until EOF(1)
Line Input #1, Hold
Locate = InStr(1, Hold, "Batch", vbTextCompare) 'finds
'directories named batch
If Locate > 0 Then
DirName2 = DirName + Mid(Hold, Locate, Len(Hold) - (Locate - 1)) + "\" 'gets directory name from file
FName1 = Dir(DirName2 + "*.dat"

Do Until FName1 = ""
FName2 = Left(FName1, Len(FName1) - 3)
Name DirName2 + FName1 As DirName2 + FName2+"txt"
'renames file
FName1 = Dir
Loop
End If
Loop
Close #1
Exit Sub
ErrHandler:
MsgBox Err.Description
Close
Exit Sub
End Sub