שיתוף | המרת גיבוי אנשי קשר מMTK ל Q8
שונות וטיפים - סלולרי
2
פוסטים
2
כותבים
20
צפיות
2
עוקבים
-
שלום וברכה
עקב צורך מסויין בהמרת גיבוי אנשי קשר מMTK ל Q8
יצרתי סקריפט קצר בAI
מצ"ב הקודimport re def convert_vcard_format(input_path, output_path): with open(input_path, 'r', encoding='utf-8') as f: content = f.read() # פיצול לכרטיסים אינדיבידואליים raw_cards = re.split(r'BEGIN:VCARD', content) converted_cards = [] for card in raw_cards: if not card.strip(): continue # חילוץ נתוני השם (N) וטיפול בקיפול שורות (Soft line breaks) name_match = re.search(r'N;.*?:;=?(.*?);;;', 'BEGIN:VCARD' + card, re.DOTALL) if name_match: # הסרת סימני קיפול שורות ורווחים מיותרים encoded_name = name_match.group(1).replace('=\n', '').replace('=\r\n', '').strip() if encoded_name.startswith('='): # תיקון למקרה שהערך התחיל בשורה חדשה encoded_name = encoded_name[1:] if encoded_name.startswith('=') and not encoded_name.startswith('=D7') else encoded_name else: encoded_name = "" # חילוץ מספרי טלפון phone_matches = re.findall(r'TEL;VOICE;CELL:(.*)', card) # בניית הכרטיס החדש במבנה המדויק new_card = "BEGIN:VCARD\r\nVERSION:2.1\r\n" if encoded_name: # שדה N עם פרמטרים בסדר הנכון new_card += f"N;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:;{encoded_name};;;\r\n" # הוספת שדה FN new_card += f"FN;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:{encoded_name}\r\n" # הוספת טלפונים בפורמט מקוצר for phone in phone_matches: new_card += f"TEL;CELL:{phone.strip()}\r\n" new_card += "END:VCARD" converted_cards.append(new_card) # כתיבה לקובץ חדש עם סיומות שורות מתאימות (CRLF) with open(output_path, 'w', encoding='utf-8', newline='') as f: f.write("\r\n".join(converted_cards) + "\r\n") # הרצת ההמרה convert_vcard_format('vcard.vcf', 'vcard_converted.vcf')צריך שהגיבוי הישן יהיה באותה תיקייה בשם vcard.vcf
בהצלחה
-
שלום וברכה
עקב צורך מסויין בהמרת גיבוי אנשי קשר מMTK ל Q8
יצרתי סקריפט קצר בAI
מצ"ב הקודimport re def convert_vcard_format(input_path, output_path): with open(input_path, 'r', encoding='utf-8') as f: content = f.read() # פיצול לכרטיסים אינדיבידואליים raw_cards = re.split(r'BEGIN:VCARD', content) converted_cards = [] for card in raw_cards: if not card.strip(): continue # חילוץ נתוני השם (N) וטיפול בקיפול שורות (Soft line breaks) name_match = re.search(r'N;.*?:;=?(.*?);;;', 'BEGIN:VCARD' + card, re.DOTALL) if name_match: # הסרת סימני קיפול שורות ורווחים מיותרים encoded_name = name_match.group(1).replace('=\n', '').replace('=\r\n', '').strip() if encoded_name.startswith('='): # תיקון למקרה שהערך התחיל בשורה חדשה encoded_name = encoded_name[1:] if encoded_name.startswith('=') and not encoded_name.startswith('=D7') else encoded_name else: encoded_name = "" # חילוץ מספרי טלפון phone_matches = re.findall(r'TEL;VOICE;CELL:(.*)', card) # בניית הכרטיס החדש במבנה המדויק new_card = "BEGIN:VCARD\r\nVERSION:2.1\r\n" if encoded_name: # שדה N עם פרמטרים בסדר הנכון new_card += f"N;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:;{encoded_name};;;\r\n" # הוספת שדה FN new_card += f"FN;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:{encoded_name}\r\n" # הוספת טלפונים בפורמט מקוצר for phone in phone_matches: new_card += f"TEL;CELL:{phone.strip()}\r\n" new_card += "END:VCARD" converted_cards.append(new_card) # כתיבה לקובץ חדש עם סיומות שורות מתאימות (CRLF) with open(output_path, 'w', encoding='utf-8', newline='') as f: f.write("\r\n".join(converted_cards) + "\r\n") # הרצת ההמרה convert_vcard_format('vcard.vcf', 'vcard_converted.vcf')צריך שהגיבוי הישן יהיה באותה תיקייה בשם vcard.vcf
בהצלחה