在该文件夹新建一Excel文件,打开该新Excel,按Alt+F11进入宏界面,点菜单的插入,模块,在新窗口粘贴如下代码:
Sub Find()
Dim MyDir, Match As String
Dim i As Integer
i = 1
MyDir = ThisWorkbook.Path & "\"
ChDrive Left(MyDir, 1)
ChDir MyDir
Match = Dir$("*.txt")
Do
If i Mod 10 = 1 Then MkDir "Txt" & Int((i - 1) / 10)
FileCopy Match, "Txt" & Int((i - 1) / 10) & "\" & Match
Kill Match
i = i + 1
Match = Dir$
Loop Until Len(Match) = 0
End Sub
在此界面直接按F5运行此宏,完成。