Deleting unfound external files

Deleting unfound external files

Post by John » Fri, 09 Jun 2006 22:51:13


Hi

How can I do this programmatically;

1. Read the first file in a folder.

2. Search for its path+name in a field in a table.

3. If not found, delete the file in the folder.

4. Repeat from step1 until all files in the folder checked.

Thanks

Regards
 
 
 

Deleting unfound external files

Post by Douglas J » Sat, 10 Jun 2006 01:01:28

Something like the following untested air-code:

Dim strFolder As String
Dim strFile As String

strFolder = "C:\Some Folder\Some Subfolder\"
strFile = Dir$(strFolder & "*.*")
Do While Len(strFile) > 0
If IsNull(DLookup("[SomeField]", "[SomeTable]", _
"[PathAndFile] = '" & strFolder & strFile & "'") Then
Kill strFolder & strFile
End If
strFile = Dir()
Loop

--
Doug Steele, Microsoft Access MVP
http://www.yqcomputer.com/
(no e-mails, please!)