Jump to content

Snippet import from CSV files


Recommended Posts

Hi,

 

I have tons of text snippets saved in TextExpander. Like many people do. Since Alfred becomes powerful on that topic, I wanted to fully change to Alfred and leaving TextExpander behind. Why using two Apps when it can be done with just one, right? But as you can imagine, "converting" all TextExpander Snippets into Alfred by hand would be a hell of work, that I am not willing to do. As far as I'm aware, there's actually no import function to import snippets from CSV files?

 

So that would be a very handy feature to have. Or at least some kind of script that does the job ones (which most of the times would be case anyway).

 

I thought of coding a script myself in Python. But as I understand, snippets now get stored in a binary alfdb file.

 

Thank you very much!

Michael

Link to post
Share on other sites
14 hours ago, deanishe said:

 

Thanks for the answer. I knew this script already. I thought 4 years not updated it might not work on Alfred 4 since the description says it was designed for Alfred 3.

Anyways, I did a little research and found out, that it is actually very easy to create these *.alfredsnippets files which one need to import snippets into Alfred 4. Since the derickfay script describes the process a little different (to put the files into the Contents folder). Which does not work anymore, because as far as I understand, the snippets get stored into a binary *.alfdb file.

 

So I decided to write my own script and add a little spice to it: https://bit.ly/2IgVrRH 

Link to post
Share on other sites
48 minutes ago, FooFourtyOne said:

I thought 4 years not updated it might not work on Alfred 4 since the description says it was designed for Alfred 3.

 

It doesn't need updating.

 

31 minutes ago, FooFourtyOne said:

because as far as I understand, the snippets get stored into a binary *.alfdb file

 

That's just a cache (workflows can also contain snippets). Snippets still go in the snippets subdirectory of your Alfred.alfredpreferences bundle.

 

34 minutes ago, FooFourtyOne said:

these *.alfredsnippets files which one need to import snippets into Alfred 4

 

That's not required. You can still just save them as JSON files to the Alfred.alfredpreferences bundle exactly as described in the script README.

 

Link to post
Share on other sites
  • 4 months later...

I'm trying to make this script work and I'm running into some issues. I downloaded the script to a folder that contains just the imporSmippets.py file and the exported snippets.textexpander file (from TE 5.16).

 

When I ran the script I got 

 

Traceback (most recent call last):

  File "./importSnippets.py", line 17, in <module>

    with open (sourceFile, 'rt') as csvfile:

IOError: [Errno 2] No such file or directory: 'snippets.csv'

 

So I ran > touch snippets.csv to create the file

 

After that it ran fine, but created no output. 

 

I'm on Big Sur 11.2.1

Link to post
Share on other sites
1 hour ago, Blfarris said:

I'm trying to make this script work and I'm running into some issues. I downloaded the script to a folder that contains just the imporSmippets.py file and the exported snippets.textexpander file (from TE 5.16).

 

When I ran the script I got 

 

Traceback (most recent call last):

  File "./importSnippets.py", line 17, in <module>

    with open (sourceFile, 'rt') as csvfile:

IOError: [Errno 2] No such file or directory: 'snippets.csv'

 

So I ran > touch snippets.csv to create the file

 

After that it ran fine, but created no output. 

 

I'm on Big Sur 11.2.1

 

Try this, maybe it helps

 https://bit.ly/2IgVrRH 

Link to post
Share on other sites

I am trying to use the original script referenced here, but I do not understand where Alfred stores snippets. Thus far, I've looked in Library/Application Support, but there are no Alfred folders in there. I'm running the latest version of Alfred on Catalina.

 

Also, I have a sinking feeling that this original script won't work for me, as I have to export my TextExpander snippets from my online account and the only option for the csv export from their website does not include the snippet name – after running the script, there are a lot less .json files than snippets I'm trying to import.  (my desktop app is thrashed and I've spent two weeks with Smile trying to get it to sync with their servers and hence the reason for my jump to Alfred for this). However, I need to know where to stick the .json files to see what has happened thus far.

Link to post
Share on other sites
44 minutes ago, Marked said:

Library/Application Support, but there are no Alfred folders in there

 

You sure you looked in the right place? It’s not /Library/Application Support, it’s in ~/Library/Application Support (i.e. in your home directory).

 

Link to post
Share on other sites
1 hour ago, deanishe said:

 

You sure you looked in the right place? It’s not /Library/Application Support, it’s in ~/Library/Application Support (i.e. in your home directory).

 

Apologies for my misunderstanding. Looking in the correct path, I see /Application Support but I don't see anything deeper as described in the script post. I can see the snippets.alfdb file inside of the Databases folder. I do not see /snippets/groupname as described for using the script. Also, does groupname refer to Collections? I've already started using Alfred and created a few snippets from scratch.

Link to post
Share on other sites
40 minutes ago, Marked said:

I can see the snippets.alfdb file inside of the Databases folder.

 

I don’t understand. The Databases folder is inside Alfred’s folder.

 

Look, your snippets are stored inside your Alfred.alfredpreferences bundle. The simplest way to go straight to that is to open a workflow in Alfred Preferences, right-click on it, and choose Open in Finder. Two directories up from there, you'll find your "snippets" folder.

Link to post
Share on other sites

Sorry, I guess I am not correctly reading the script readme file. My understanding is that I should move these .json files into .../Alfred.alfredpreferences/snippets/groupname. This is how I started digging into the Application Support folder. I clearly do not understand your directions and and need someone to explain this me like I'm a five year-old. I'll reach out to tech support and step away. Thank you for trying to help me out.

Link to post
Share on other sites
9 hours ago, Marked said:

My understanding is that I should move these .json files into .../Alfred.alfredpreferences/snippets/groupname.

 

That is correct. Thing is, your actual Alfred.alfredpreferences bundle might not be in ~/Library/Application Support/Alfred. If you've turned on preference syncing, it's somewhere else.

 

So if you ever want to access your preferences bundle, the safest way to ensure you're in the right place is to open a workflow in Finder from Alfred Preferences because your workflows are also in the Alfred.alfredpreferences bundle:

 

Alfred.alfredpreferences/
  ...
  snippets/
    Collection 1/
    Collection 2/
    ...
    My New Collection/
      YOUR SNIPPETS GO HERE.json  <-------------------------
      ...
  themes/
  workflows/
    ...
    user.workflow.BLAH-BLAH-BLAH/
       YOU ARE HERE!  <-------------------------------------
    ...

 

Once you’ve found the right snippets folder, create a new folder within it called whatever it is you want to call your snippet collection, then put the actual JSON snippet files in there.

Edited by deanishe
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...