1、dir递归查找当前文件夹下的每一个文件。
2、open打开文件,line input读到第10
3、left、right、mid等找出行关键字。
4、fielcopy、kill等语句移动文件

解决方案 »

  1.   


    Dim strFile As String, strData As String, strLine As String
    Dim strKeywords As String, strPath As String
    Dim i As IntegerstrPath = "C:\text\"
    strKeywords = "AIRUDQF"'Prepare the Subdirectories
    For i = 1 To 7
        If Dir(strPath & Mid(strKeyword, i, 1), vbDirectory) = "" Then MkDir strPath & Mid(strKeyword, i, 1)
    Next istrFile = Dir(strPath & "*.txt")
    Do Until strFile = ""
        Open strPath & strFile For Input As #1
        strData = Input(LOF(1), #1)
        Close #1
        strLine = Split(strData, vbCrLf)
        For i = 1 To 7
            If InStr(strLine(9), Mid(strKeywords, i, 1)) Then
                Name strPath & strFile As strPath & Mid(strKeywords, i, 1) & "\" & strFile 'Move the file into subdirectory
                Exit For
            End If
        Next i
        strFile = Dir()
    Loop