'____________________ PARAMETRES ______________________ DossierSource = "C:\DossierAFB\SOURCE\" DossierDestination = "C:\DossierAFB\DESTINATION\" EcraserSiLeFichierExiste = False '____________________ PARAMETRES ______________________ Set fso = CreateObject("Scripting.FileSystemObject") Set objFolder = fso.GetFolder(DossierSource) Set colFiles = objFolder.Files Dim intNbFichiersDupliques intNbFichiersDupliques = 0 For Each objFile in colFiles DestinationFile = DossierDestination & "\" & fso.GetFileName(objFile) 'Check to see if the file already exists in the destination folder If fso.FileExists(DestinationFile) Then If EcraserSiLeFichierExiste = True Then 'Check to see if the file is read-only If Not fso.GetFile(DestinationFile).Attributes And 1 Then 'The file exists and is not read-only. Safe to replace the file. fso.CopyFile objFile, DossierDestination, True intNbFichiersDupliques = intNbFichiersDupliques + 1 Else 'The file exists and is read-only. 'Remove the read-only attribute fso.GetFile(DestinationFile).Attributes = fso.GetFile(DestinationFile).Attributes - 1 'Replace the file fso.CopyFile objFile, DossierDestination, True intNbFichiersDupliques = intNbFichiersDupliques + 1 'Reapply the read-only attribute fso.GetFile(DestinationFile).Attributes = fso.GetFile(DestinationFile).Attributes + 1 End If End If Else 'The file does not exist in the destination folder. Safe to copy file to this folder. fso.CopyFile objFile, DossierDestination, True intNbFichiersDupliques = intNbFichiersDupliques + 1 End If Next Set fso = Nothing Wscript.Echo intNbFichiersDupliques & " fichier(s) duplique(s)"