Split a multi vCard file into separate files

If you export multiple contacts from the Lotus Notes Personal Address book to a vCard, Lotus Notes generates a single vCard file rather than a file per contact. This means that if you want to import the contacts to something, say like MS Outlook the file needs to be separated. There are probably a number of ways that a text based file can be split into separate files, however I chose to make use of the following Powershell script..

clear-host
$ifile = $args[0]
If( $ifile -eq $NULL )
{
Write-Host Usage: .\vcfrw.ps1filename.vcf
Write-Host Examp: .\vcfrw.ps1 c:\vcf\joe.vcf
Exit
}
Write-Host Processing Lotus Notes vCard File: $ifile

$i = 1
switch -regex -file $ifile
{
"^BEGIN:VCARD" {if($FString){$FString |
out-file -Encoding "ASCII" "$ifile.$i.vcf"};$FString = $_;$i++}
"^(?!BEGIN:VCARD)" {$FString+="`r`n$_"}
}

Write-Host VCard Processing Complete
Write-Host Processed $i VCard entries 

Very handy if your in a rush to dump out a Lotus Notes users contacts and give something meaningful.

Advertisements

2 thoughts on “Split a multi vCard file into separate files

  1. Pingback: Diviser un fichier vCard en de multiples fichiers séparés avec Powershell | Claude Couderc

  2. Pingback: Diviser un fichier vCard en de multiples fichiers séparés avec Powershell | Sécurité informatique

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s