Copier la différence d'un dossier dans un autre

megakorn01 Messages postés 1 Date d'inscription vendredi 22 août 2008 Statut Membre Dernière intervention 16 décembre 2008 - 16 déc. 2008 à 22:56
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 - 17 déc. 2008 à 11:36
Salut,

Voici mon problème, outre que je ne connaisse presque rien au VBS. Nous avons des bases de données SQL server et tous les 15 minutes, des TRN se génère dans un dossier. Par souci de sécurité, un script copie le dossier intégral sur d'autres disques.
Mais il faut qu'un script vbs s'exécute tous les 1/4 d'heure pour copier les nvx fichiers.

 J'ai commencé par faire ça :


Set objFSO = CreateObject("Scripting.FileSystemObject")

Set Source = objFSO.GetFolder("C:\TRN\nom")

Set CollectFichierSource = Source.Files

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set Destination = objFSO.GetFolder("E:\TRN\nom")

Set CollectFichierDestination = Destination.Files


For each  Fichier in CollectFichierSource

    wscript.echo Fichier.name

Next

For each  Fichier in CollectFichierDestination

    wscript.echo Fichier.name

Next

La, ca va. Par contre, je ne sais pas comment faire pour lui dire pour qu'il me copie les fichiers qu'il y a dans Source vers Destination pour que le dossier Destination soit identique au dossier Source toutes les 15 minutes.
Toutes les 15 minutes, ca OK avec une tâche planifiée car sous Windows.
Et la, il n' y en a que 2 dossiers !!!

Merci d'avance !!!
Bonne soirée !!!

1 réponse

cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
17 déc. 2008 à 11:36
 Bonjour,

Il suffit d'utiliser la fonction CopyFile.

Option explicit
Const PathInfile  = "C:\TEST"           
Const PathOutfile  = "D:\TEST"

msgbox FnCopyFile()

Function FnCopyFile()
   Dim objFso, objFile, strListe
   Set objFso = CreateObject("Scripting.FileSystemObject")

   For Each objFile in objFso.GetFolder(PathInfile).Files
       objFso.CopyFile objFile.Path, PathOutfile & objFile.Name, True
       strListe = strListe & vbCrLf & objFile.Path
   Next

   FnCopyFile = "Fichiers copiés" & vbCrLf & strListe
   Set objFso = Nothing
End Function

Voir aussi la fonction CopyFolder:

Option explicit
Const PathInfile  = "C:\TEST"           
Const PathOutfile  = "D:\TEST"

Call FnCopyFolder()

Function FnCopyFolder()
   Dim objFso
   Set objFso = CreateObject("Scripting.FileSystemObject")
   objFso.CopyFolder PathInfile, PathOutfile
   Set objFso = Nothing
End Function

Merci de poster dans le bon thème:
Vous êtes ici : Thèmes

/ [forum-VISUAL-BASIC_1.aspx Visual Basic 6] / [theme-LANGAGES-DERIVES_287.aspx Langages dérivés] / [theme-VBSCRIPT_245.aspx VBScript]

jean-marc
0
Rejoignez-nous