Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionOption Explicit Const PathInput = "C:\envoi\attente_echantillon" ShowFolderList() Function ShowFolderList() Dim objFso, colFile Dim strFile, strDateFile, PathOutput Set objFso = CreateObject("Scripting.FileSystemObject") For Each colFile in objFso.GetFolder(PathInput).Files strFile = objFso.GetBaseName(colFile.Name) If LCase(objFso.GetExtensionName(colFile.Name)) = "txt" And _ InStr(LCase(colFile), "gestion") <> 0 And _ Len(objFso.GetBaseName(colFile.Name)) >= 14 Then strDateFile = Right(strFile, 14) If IsDate(checkDate(strDateFile)) = True Then MsgBox "date ok" & vbCrLf & checkDate(strDateFile),,colFile.Name If DateDiff("h", checkDate(strDateFile), Now) >= 24 Then If InStr(UCase(strFile),"_MP_") Then objFso.DeleteFile colFile.Path Else If InStr(UCase(strFile),"_CE_") Then PathOutput = "C:\envoi\incomplets\centrale_mesure" ElseIf InStr(UCase(strFile),"_ME_") Then PathOutput = "C:\envoi\incomplets\metrologie" ElseIf Instr(UCase(strFile),"_3D_") Then PathOutput = "C:\envoi\incomplets\3D" Else PathOutput = "C:\envoi\incomplets\Autres" End If If Not objFso.FileExists(PathOutput & colFile.Name) Then objFso.MoveFile colFile.Path, PathOutput Else MsgBox PathOutput & colFile.Name,,"fichier non déplacé car déjà existant en sortie" End If End If Else MsgBox strFile,,"date antérieure à 24h" End if Else MsgBox colFile.Path &vbCrLf& strDateFile,,"Date incorrecte" End If Else MsgBox strFile,,"Fichier non conforme" End if Next Set objFso = Nothing End Function Function checkDate(strDateFile) checkDate = Mid(strDateFile,7,2) & "/" &_ Mid(strDateFile,5,2) & "/" &_ Left(strDateFile,4) & Space(1) &_ Mid(strDateFile,9,2) & ":" &_ Mid(strDateFile,11,2) & ":" &_ Right(strDateFile,2) End Function