تفضل .....
Private Sub Command_Click()
Call DeleteImageFiles
DoCmd.Quit
End Sub
Sub DeleteImageFiles()
Dim fso As Object
Dim folderPath As String
Dim file As Object
' تحديد مسار المجلد المطلوب
folderPath = CurrentProject.Path & "\Data\QR_images\"
' التأكد من وجود المجلد
If Dir(folderPath, vbDirectory) = "" Then
MsgBox "المجلد غير موجود: " & folderPath, vbExclamation, "خطأ"
Exit Sub
End If
' إنشاء كائن FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject")
' التحقق من الملفات داخل المجلد
For Each file In fso.GetFolder(folderPath).Files
' التحقق إذا كان الملف صورة (حسب الامتداد)
If LCase(file.Name) Like "*.jpg" Or _
LCase(file.Name) Like "*.jpeg" Or _
LCase(file.Name) Like "*.png" Or _
LCase(file.Name) Like "*.bmp" Or _
LCase(file.Name) Like "*.gif" Then
' حذف الملف
file.Delete True
End If
Next file
MsgBox "تم حذف جميع ملفات الصور بنجاح!", vbInformation, "عملية ناجحة"
' تحرير الكائنات
Set fso = Nothing
End Sub