Skip to content

Instantly share code, notes, and snippets.

@creimers
Created May 3, 2021 07:06
Show Gist options
  • Save creimers/e167714b26e3ac61aa32538f993290f3 to your computer and use it in GitHub Desktop.
Save creimers/e167714b26e3ac61aa32538f993290f3 to your computer and use it in GitHub Desktop.
Python script to remove images from vcards (vcf) files.
import argparse
def main(file_path):
with open(file_path, "r") as the_file:
content = the_file.read()
new_lines = []
for line in content.split("\n"):
if (";" not in line and ":" not in line) or "PHOTO" in line:
pass
else:
new_lines.append(line)
with open("pictureless.vcf", "w") as output:
output.write("\n".join(new_lines))
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--path')
parsed_args = parser.parse_args()
main(parsed_args.path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment