Bonjour,
Je vais changer de portable alors j'ai fait une sauvegarde du répertoire de contact que j'ai envoyé par le port infra rouge sur mon pc.
Le problème est que le format Vcard n'est pas vraiment exploitable en l'état.
J'ai donc créé un script WSH pour convertir ce fichier en CSV et TXT pour pouvoir l'exploiter sous Excel
Je vous fournit le script, il suffit de faire un copier coller dans un notepad et de nommer le fichier EXT_Vcar.wsf
NOTE : Ce script devrait fonctionner avec d'autre fichier Vcard mais je n'ai que le M341i
<job>
<runtime>
<description>
--------------------------------------------------------------------------
Extraction d'un fichier Vcard Mitsubishi vers Txt et CSV
sans les photos
By Pimousse 02/06
--------------------------------------------------------------------------
</description>
<named
name = "vcard"
helpstring = "Fichier Vcard"
type = "string"
required = "true"
/>
<example>
exemple : cscript //nologo EXT_Vcar.wsf /vcard:vcf050326-1707.vcf
</example>
</runtime>
<script language="VBScript">
Option Explicit
' Déclaration des varibles
Dim Chaine,ChaineD,Position,Indice,Indice2,Phones(),Phones2()
ReDim Phones(0)
' Declaration de variables system
Dim fso,fileliste,dossier,fichierVcard,filelistecsv
' Instance et initialisation
Set fso = CreateObject("Scripting.FileSystemObject")
Indice=0
' Constantes pour l'access aux fichiers
Const ForReading = 1, ForWriting = 2
If Wscript.Arguments.Named.Count <>1 Then
WScript.Echo "-----------------------------------"
WScript.Echo "ERREUR : PAS BON NOMBRE D'ARGUMENTS"
Wscript.Arguments.ShowUsage
WScript.Quit 1
End If
If IsEmpty(Wscript.Arguments.Named.Item("vcard")) Or IsNull (Wscript.Arguments.Named.Item("vcard")) Then
WScript.Echo "-----------------------------------"
WScript.Echo "ERREUR : ARGUMENTS vcard"
Wscript.Arguments.ShowUsage
WScript.Quit 1
End If
fichierVcard = Wscript.Arguments.Named.Item("vcard")
' Test la présence de la liste de fichier
WScript.Echo "Test la présence du fichier"
If (fso.FileExists(fichierVcard)) Then
WScript.Echo fichierVcard & " existe."
Else
WScript.Echo fichierVcard & " n'existe pas."
' Retour
Wscript.Quit (1)
End If
Set fileliste=fso.OpenTextFile(fichierVcard, ForReading) 'Ouverture du fichier la mettre dans la log
Do While Not fileliste.AtEndOfStream
Chaine = fileliste.ReadLine
Position = InStr(1, Chaine, ":")
If Position > 0 Then
Chaine = Left(Chaine, Position)
If (Chaine <> "BEGIN:") And (Chaine <> "VERSION:") And (Chaine <> "END:")And (Left(Chaine,5) <> "PHOTO") Then
If Indice = 0 Then
Phones(Indice)=Chaine
ReDim Preserve Phones(UBound(Phones,1)+1)
Indice = Indice + 1
Else
'Wscript.Echo UBound(Filter(Phones,Chaine),1) & " --- " & Chaine
If UBound(Filter(Phones,Chaine),1) = -1 Then
Phones(Indice)=Chaine
ReDim Preserve Phones(UBound(Phones,1)+1)
Indice = Indice + 1
End If
End If
End If
End If
Loop
fileliste.close
ReDim Phones2 (UBound (Phones)-1,0)
For Indice=0 To (UBound(Phones,1)-1)
Phones2(Indice,0)=Phones(Indice)
Next
Set fileliste=fso.OpenTextFile(fichierVcard, ForReading) 'Ouverture du fichier source
Do While Not fileliste.AtEndOfStream
Chaine = fileliste.ReadLine
Position = InStr(1, Chaine, ":")
If (Position > 0) And (Left(Chaine,1) <> " " )Then
ChaineD = Right(Chaine,Len (Chaine) - Position)
Chaine = Left(Chaine, Position)
If Chaine = "BEGIN:" Then
ReDim Preserve Phones2(UBound(Phones2,1),UBound(Phones2,2)+1)
End If
If (Chaine <> "BEGIN:") And (Chaine <> "VERSION:") And (Chaine <> "END:") And (Left(Chaine,5) <> "PHOTO") Then
For Indice=0 To UBound(Phones2,1)
If Phones2(Indice,0) = Chaine Then
'Phones2(Indice,UBound(Phones2,2))= Replace(ChaineD, ";", " ")
Phones2(Indice,UBound(Phones2,2))= ChaineD
End If
Next
End If
End If
Loop
fileliste.close
Set fileliste=fso.OpenTextFile(fichierVcard & ".txt", ForWriting, True,-1) 'Ouverture du fichier txt
Set filelistecsv=fso.OpenTextFile(fichierVcard & ".csv", ForWriting, True,-1) 'Ouverture du fichier csv
For Indice2=0 To UBound(Phones2,2)
For Indice=0 To UBound(Phones2,1)
fileliste.Write Chr(34) & Phones2(Indice,Indice2) & Chr(34) & vbTab
filelistecsv.Write Chr(34) & Phones2(Indice,Indice2) & Chr(34) & vbTab
Next
fileliste.Write vbCrLf
filelistecsv.Write vbCrLf
Next
fileliste.close
Wscript.Echo "Extraction Terminée"
Wscript.Echo "Fichier Généré = " & fichierVcard & ".txt"
Wscript.Echo "Fichier Généré = " & fichierVcard & ".csv"
</script>
</job>