VB Code:
inti = Dir("C:\Documents and Settings\Cesar\Desktop\in\*.*")
asum = Mid$(inti, 15, 8)
CES = Dir("C:\Documents and settings\Cesar\Desktop\rejected\*.*")
Do While CES <> ""
ASUM1 = Mid$(CES, 15, 8)
If asum = ASUM1 Then
T = T + 1
FileCopy "C:\Documents and Settings\Cesar\Desktop\rejected\" & CES, _
"C:\Documents and Settings\Cesar\Desktop\out\" & CES
End If
CES = Dir
Loop
Print T
Also, subsequent calls to Dir without a path always use the last path passed to Dir, so you can't expect to call Dir again on your "in" folder after you call Dir using your "rejected" folder.