(view source code of ldif2vcard.bat as plain text)
:: Check Windows version
:: Check command line arguments
:: use local variables
IF "%~2"=="" (
) ELSE (
:: Use 8.3 notation for LDIF file to prevent doublequotes in FOR /F argument
:: Clear the variables used in the "outer" FOR loop
REM dn: cn=... always is the first line of an address "block", so when
REM we encounter it, the previous one is complete and can be processed
REM Very basic progress monitoring
REM Check if an address was loaded already, i.e. skip processing the first time we find this dn: line
REM Skip groups and mailing lists, we will only export persons
IF "!person!"=="1" (
REM More basic progress monitoring
REM If %2 was * then we'll save each addres in its own individual vCard file,
REM using the person's name for file name; if not we'll use a single vCard file
REM Start writing the vCard
>> !vcfFile! ECHO BEGIN:VCARD
>> !vcfFile! ECHO VERSION:2.1
>> !vcfFile! ECHO N:!vCard.sn!;!vCard.givenName!;;;
>> !vcfFile! ECHO FN:!vCard.cn!
>> !vcfFile! ECHO TEL;WORK:!vCard.telephoneNumber!
>> !vcfFile! ECHO TEL;HOME:!vCard.homePhone!
>> !vcfFile! ECHO TEL;CELL:!vCard.mobile!
>> !vcfFile! ECHO EMAIL;PREF:!vCard.mail!
>> !vcfFile! ECHO EMAIL;HOME:!vCard.mozillaSecondEmail!
>> !vcfFile! ECHO ADR;WORK:;;!vCard.street!;!vCard.l!;;!vCard.postalCode!;
>> !vcfFile! ECHO ADR;HOME:;;!vCard.mozillaHomeStreet!;!vCard.mozillaHomeLocalityName!;;!vCard.mozillaHomePostalCode!;
>> !vcfFile! ECHO END:VCARD
REM Clear file name variable or add an empty line, depending on %2
REM Clear the variables again
REM Check if the address block is a person's address
REM Save each value from the LDIF file in a variable
ECHO LDIF2vCard.bat, Version 0.11 alfa
ECHO Very basic LDIF to vCard converter
ECHO written to its own individual file, named after the person.
ECHO a single *.vcf file, named after the input file.
ECHO This batch file has hardly been tested, use it at your own risk.
ECHO would be to "escape" these with carets first, and remove the
ECHO batch file to make it meet your requirements.
ECHO Written by Rob van der Woude
|page last uploaded: 2017-07-06, 12:37|