Jump to content

kpw

Member
  • Posts

    4
  • Joined

  • Last visited

Posts posted by kpw

  1. You can right-click on the snippet collection you are interested in and choose "Export".

     

    Then this python3 script should print the details out (change "snippetExportFile" with your exported filename).

     

    #!/usr/bin/env python3
    
    from zipfile import ZipFile
    import os 
    import json
    
    snippetExportFile = '/Users/kpw/Desktop/kpw.alfredsnippets'
    
    with ZipFile(snippetExportFile, 'r') as zip:
        files = zip.filelist
        for zipfile in files:
            if zipfile.filename.endswith(".json"):
                with zip.open(zipfile.filename) as myfile:
                    snippetFileJson = myfile.read()
                    alfredDict = json.loads(snippetFileJson.decode('utf-8'))
                    snippetDict = alfredDict["alfredsnippet"]
                    print(f'Name:\t\t{snippetDict["name"]}')
                    print(f'Keyword:\t{snippetDict["keyword"]}')
                    snippetText = snippetDict["snippet"].replace("\n", "\\n")
                    print(f'Snippet:\t{snippetText}')
                    print("-" * 80)

     

×
×
  • Create New...