Hi
Each record starts "BEGIN:VCARD" with and ends with "END:VCARD"
Output can start with 1.vcf to as many as they are.
Thanks
Split Multiple vCard vcf file into many
Moderator: DosItHelp
Re: Split Multiple vCard vcf file into many
Start the Batch file with
and then put the rest of commands...
At the very beginning of this site there is this thread, so there is no way that you had not see it...
Antonio
Code: Select all
@echo off
At the very beginning of this site there is this thread, so there is no way that you had not see it...
Antonio
Re: Split Multiple vCard vcf file into many
Thank you Antonio, I visited the thread you mentioned.
Blame it on old age (70), blame it on stupidity, I do not get it!
Please set forth exactly what you are asking me to supply.
Note:
As an alternative to numbered files output, please show the code for "LastName(.FirstName.MiddleName)*.vcf" output.
*Omit parenthesis if record is missing this data.
Blame it on old age (70), blame it on stupidity, I do not get it!
Please set forth exactly what you are asking me to supply.
Note:
As an alternative to numbered files output, please show the code for "LastName(.FirstName.MiddleName)*.vcf" output.
*Omit parenthesis if record is missing this data.
Re: Split Multiple vCard vcf file into many
Ok. To clarify what the first thread is asking for, I suggest you to carefully read this post. After that, answer these questions:
Antonio
PS: I may have spent more time writing this long answer than it would have taken to write the desired batch file... This means that largely incomplete questions like this one are frowned upon here
- How many input files do you want to process? One? Many?
- Please, post here a small example of an input file enclosed between [code] and [/code] tags. Of course, we could guess the format of the input files. However, in order to test the code we could write, we need to also write an input data example file! Do you want that we also write such a data file?
- Post the desired output files than should result after processing the listed input example file.
- Do you want to generate output files with names as 1,2,...9,10,11,...? Mean this that the order of the output files don't matters? Or do you want names with (for example) 3 digits like 001, 002,...009,010,011...
- Do you want to preserve of remove the processed input files? If preserved, they will mix with the generated output files, but the program could delete each processed file... Unless the output files be placed in a different directory than the input file...
- Should I continue with this?
Antonio
PS: I may have spent more time writing this long answer than it would have taken to write the desired batch file... This means that largely incomplete questions like this one are frowned upon here
Re: Split Multiple vCard vcf file into many
This code do what the OP requested, more or less...
test.vcf input file:
Put the name of input file in the parameter. For example:
Antonio
Code: Select all
@echo off
setlocal EnableDelayedExpansion
set "num=1"
for /F "delims=" %%a in (%1) do (
>> !num!.vcf echo %%a
if "%%a" equ "END:VCARD" set /A num+=1
)
Code: Select all
BEGIN:VCARD
TYP:SMS;IN
BOX:INBOX
READ:0
DATE:20211102T113146U
NUMBER:6012589631
BODY;CHARSET=1253
END:VCARD
BEGIN:VCARD
TYP:SMS;IN
BOX:INBOX
READ:0
DATE:20211102T104259U
NUMBER:6256945389
BODY;CHARSET=1253:TEST
END:VCARD
BEGIN:VCARD
TYP:SMS;IN
BOX:INBOX
READ:0
DATE:20220118T090000U
NUMBER:1234567890
BODY;CHARSET=1253:TEST
END:VCARD
Code: Select all
C:\Users\Antonio\Documents\Test> test test.vcf
C:\Users\Antonio\Documents\Test> type 1.vcf
BEGIN:VCARD
TYP:SMS;IN
BOX:INBOX
READ:0
DATE:20211102T113146U
NUMBER:6012589631
BODY;CHARSET=1253
END:VCARD
C:\Users\Antonio\Documents\Test> type 2.vcf
BEGIN:VCARD
TYP:SMS;IN
BOX:INBOX
READ:0
DATE:20211102T104259U
NUMBER:6256945389
BODY;CHARSET=1253:TEST
END:VCARD
C:\Users\Antonio\Documents\Test> type 3.vcf
BEGIN:VCARD
TYP:SMS;IN
BOX:INBOX
READ:0
DATE:20220118T090000U
NUMBER:1234567890
BODY;CHARSET=1253:TEST
END:VCARD
Re: Split Multiple vCard vcf file into many
Thank you Aacini.
To the point as always!
As an alternative to numbered files output, would it be too hard to code for "LastName.FirstName.MiddleName.vcf" output?
That info is stored in the line always starting with "N:"
Sample input file:
To the point as always!
As an alternative to numbered files output, would it be too hard to code for "LastName.FirstName.MiddleName.vcf" output?
That info is stored in the line always starting with "N:"
Sample input file:
BEGIN:VCARD
VERSION:3.0
N:Last;First;Middle;Prefix(Mr.);Suffix(Sr.)
FN:First Last
TEL;TYPE=CELL:123-456-7777
TEL;TYPE=HOME:222-333-4444
END:VCARD
BEGIN:VCARD
VERSION:3.0
N:Smoe;Joe;Jim;Dr.;
FN:Joe Smoe
TEL;TYPE=HOME:222-222-2222
TEL;TYPE=CELL:999-999-9999
END:VCARD