"Import TextExpander Group" Macro

Hey Ian,

Nope. Please yourself, but try to make the versioning really obvious.

Here's the sort of thing I do:


I really wish the comment action would allow RTF content, so I could put a monospaced font in there. It's hard to create nicely aligned readable comments using a proportional font.

I have a comment saved to a named-clipboard, and I use a macro to paste it into the working macro with a keystroke.

It's also a good idea to give the macro file itself a version number.

-Chris

Nice, I wasn't aware that you could change the title of actions. Versioning comment is now a thing, along with a few minor improvements to the macro's display in Keyboard Maestro (no functional changes).

Is there a way to upload .kmmacros files to the forum without needing to use the "share" button in-app? It doesn't look like there's any good way to set the specific file name without modifying the name of the macro itself using that method (which was what I've been doing until now).

A post was split to a new topic: Export Selected Macros

This script is genius. Many thanks.

I have a TON of TE snippets. We are talking thousands. Will I overload KM if I import them all? Any caveats?

I'm not sure; I haven't run into any trouble, but mine are numbered in the hundreds. The import does generate the necessary XML for importing the snippets in memory, so it could potentially lead to problems if that got too big but realistically snippets are all text, and usually not all that long, which means they take up negligible amounts of space. If you're worried, maybe try selecting just one or two .textexpander files at a time and import them piecemeal. If you don't have any performance issues, you can always select more files for the next import.

I don't have any idea what performance hit--if any--that many text expansions will have on Keyboard Maestro; maybe other forums members can chime in on that, since I don't have very many actions of any kind (having just started using it recently).

As described in Import/convert 600 TextExpander macros for KM, Keyboard Maestro Engine can handle more or less any number of text expansion macros, but each simple typed string macro occupies about 200 bytes in the monolithic macro save file. This makes 200K per thousand expansions. Depending on the speed of your Mac and your harddisk, the editor may start to slow down if you have many thousands of such expansions.

Thank you, Peter!

Thank you so much for sharing this, just installed all my snippets, and it was so fast, just need to do some tweaking on some fill-in snippets, but works like a charm. :smile:

Thanks. Worked flawlessly for 8/10 groups. For the two groups that failed I simply created new groups/folders in TE and dragged the snippets to the new ones and the export/import into KM went perfect.

Thank you for this, it worked well for me. However, is it possible to have the keyboard maestro macros insert the text by typing instead of pasting? The reason is that when using these macros in Word the snippet often replaces the clipboard so that at the next ‘paste’ the snippet is inserted again instead of whatever was previously typed.
As an alternative, is it possible to ‘batch edit’ all the imported snippet macros and change them all from insert by pasting to insert by typing?
Thanks for any suggestions.

However, is it possible to have the keyboard maestro macros insert the text by typing instead of pasting?

Insert Text By Typing had significantly worse performance when I was originally testing my migration logic, which is why the macro uses pasting by default. You can certainly change it, though:

  1. Open the "Import TextExpander Group" macro

  2. Toggle open "For each selected `.textexpander` file in Finder, parse snippets"

  3. Toggle open "Convert TE snippet XML to macro XML"

  4. Find the code that looks like this (about halfway down):

     <key>Action</key>
     <string>ByPasting</string>
     <key>MacroActionType</key>
     <string>InsertText</string>
     <key>Paste</key>
     <true/>
    
  5. Replace it with this:

     <key>Action</key>
     <string>ByTyping</string>
     <key>MacroActionType</key>
     <string>InsertText</string>
    

Please note that I'm guessing at the need to remove the <key>Paste</key> stuff; if things don't work after making my change above, try just changing ByPasting to ByTyping instead.

Good luck!

Wow! I can’t believe how swiftly you responded to that!
The change did work for me, and yes you do need to keep the Paste line or the macro fails.
Thanks a ton!

Just some follow up: because I was still having some clipboard trouble due to the ‘set clipboard’ action that followed every paste in macro I also removed:
MacroActionType
SetClipboardToPastClipboard
PastExpression
1

Now it just inserts by typing and working great. Really appreciate you’re making this and responding to me!

This looks great, but has anyone written anything similar to deal with more data files? (Typinator, csv text, etc)?

Or heck, I have a file designed to be added into the Apple autocorrection database

		<dict>
			<key>on</key>
			<integer>1</integer>
			<key>replace</key>
			<string>downlaod</string>
			<key>with</key>
			<string>download</string>
		</dict>

When I run this macro on .textexpander files I get the pop-up message "The file was read, but no macros were imported." If I try it again and enable debugging, I get the following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>

<dict>
    <key>Activate</key>
    <string>Normal</string>
    <key>Name</key><string>Exp: Date</string>
<key>Macros</key>
    <array>
    </array></dict>
</array>
</plist>

Is the file type for Textexpander 6.5.2 not compatible with the older macro? @onecrayon

1 Like

I also get this error message. I know I've used this macro in the past successfully, so something must have changed with the .textexpander file in the interim.

I'm wondering if it has anything to do with the fact that I've switched (maybe you have too) to the subscription model instead of the local-only model, and it looks like the local data file has changed. Instead of .textexpander it's now .textexpanderlocal

Yes, I'm on the subscription plan as well. Frustrating, because I would love to be able to get my replacements into KM without having to regenerate each by hand. Data lock-in is no fun.

Unfortunately, I haven’t used TextExpander in years (switched to Keyboard Maestro and never looked back), so I can’t really help if the file format has changed. Good luck!

1 Like

Help me Obi-@onecrayon, you're my only hope!

:grin: