VBA – Folders and Files Functions

Check if folder is empty:
Public Function FolderIsEmpty(myPath As String) As Boolean
    FolderIsEmpty = CBool(Dir(myPath & "*.*") = "")
End Function
Delete all files in a folder:
Public Sub DeleteAllFiles(path As String)
    Kill path & "*.*"
End Sub
Create text file in a given path with text:
Public Sub CreateTextFile(path As String, fileName As String, text As String)
    
    Dim fso As Object
    Dim file As Object
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set file = fso.CreateTextFile(path & fileName, True)
    
    file.WriteLine text
    file.Close

End Sub
All together:
Sub Main()
    
    Dim path As String
    path = "C:\Users\Username\Desktop\New folder\"
    CreateTextFile path, "to_delete.txt", "some text inside the file"
    
    If Not FolderIsEmpty(path) Then
        DeleteAllFiles path
    End If
    
End Sub