フォルダー内14日経過ファイルを削除

Sub delete_file()
    Dim base_path, extension, file_name As String
    Dim file_date As Date
    Dim Diff_day, Diff_week, Diff_month As Integer
    base_path = "C:\Users\Desktop\test"
    extension = "JPG"
    file_name = Dir(base_path & "\*" & extension, vbNormal)
    Do Until file_name = ""
        file_date = FileDateTime(base_path & "\" & file_name)
        Diff_day = DateDiff("d", file_date, Now())
        Diff_week = DateDiff("w", file_date, Now())
        Diff_month = DateDiff("m", file_date, Now())
        If Diff_day > 14 Then '←ここ
            Kill base_path & "\" & file_name
        End If
        file_name = Dir()
    Loop
End Sub

最新の作成時間ファイルを移動する