当需要创建大量文件夹及文件时,可借助excel vba 实现,如下图:
批量创建文件名为1-10的文件夹,每个文件夹内有个与文件名相同的txt文件,txt文件内的数字也跟文件名相同。

 
 
附代码:
Sub CreateFoldersAndFiles()
    Dim i As Integer
    Dim folderPath As String
    Dim filePath As String
    Dim textFile As Integer
    
    ' 获取当前Excel文件所在的文件夹路径
    folderPath = ThisWorkbook.Path & "\"
    
    ' 循环创建10个文件夹和txt文件
    For i = 1 To 10
        ' 创建文件夹
        MkDir folderPath & i
        
        ' 生成txt文件路径
        filePath = folderPath & i & "\" & i & ".txt"
        
        ' 创建并写入txt文件
        textFile = FreeFile
        Open filePath For Output As textFile
        Print #textFile, i
        Close textFile
    Next i
    
    MsgBox "文件夹和文件创建完成!" 
End Sub
 
代码代写,可点击下方联系 ↓



















