I would like to permanently delete files from one folder on the c: drive off the c: drive. I have been using the following code to move files between folders but I would like to automate the process. Thanks for your help in advance!
Sub MoveFiles()
Dim strFolderA As String
Dim strFolderB As String
Dim strFile As String
Dim cnt As Long
On Error Resume Next
'//Change the path to the source folder, accordingly
strFolderA = "C:\Work\"
'//Change the path to the destination folder, accordingly
strFolderB = "C:\trash\"
If Right(strFolderA, 1) <> "\" Then strFolderA = strFolderA & "\"
If Right(strFolderB, 1) <> "\" Then strFolderB = strFolderB & "\"
'Identifies the file
strFile = Dir(strFolderA & "*.*")
''loop until no files are found
Do While Len(strFile) > 0
If Left(strFile, 1) <> "!" Then ''Looks for the "!" and will not move no matter the date
If (Date + Time) - FileDateTime(strFolderA & strFile) > 7 Then
cnt = cnt + 1
Name strFolderA & strFile As strFolderB & strFile
End If
End If
strFile = Dir
Loop
End Sub
Sub MoveFiles()
Dim strFolderA As String
Dim strFolderB As String
Dim strFile As String
Dim cnt As Long
On Error Resume Next
'//Change the path to the source folder, accordingly
strFolderA = "C:\Work\"
'//Change the path to the destination folder, accordingly
strFolderB = "C:\trash\"
If Right(strFolderA, 1) <> "\" Then strFolderA = strFolderA & "\"
If Right(strFolderB, 1) <> "\" Then strFolderB = strFolderB & "\"
'Identifies the file
strFile = Dir(strFolderA & "*.*")
''loop until no files are found
Do While Len(strFile) > 0
If Left(strFile, 1) <> "!" Then ''Looks for the "!" and will not move no matter the date
If (Date + Time) - FileDateTime(strFolderA & strFile) > 7 Then
cnt = cnt + 1
Name strFolderA & strFile As strFolderB & strFile
End If
End If
strFile = Dir
Loop
End Sub