Bottom Line: Here’s how to use my lcp_export script to batch update your Launch Center Pro actions to work with the new Drafts 4.

Drafts 4 is out, and it looks pretty sweet. It does change the URL scheme slightly but predictably, from drafts:to drafts4:, or from drafts://x-callback-url/ to x-drafts4://x-callback-url/, respectively.

If you’re reading this, I’m guessing you have a fair number of Launch Center Pro actions that need to be updated to use Drafts 4. You’re in luck — my lcp_export script seems to take most of the work out and lets you make the changes on your Mac. You’ll probably want to review that post to remind yourself how it works. Here’s how I did mine.

This assumes you have lcp_export.py installed from the post linked above. file.lcpbackup and file.json are placeholders, obviously, so you’ll need to modify the commands to match your filenames. Also note that this won’t update for any URL incompatibilities introduced by Drafts 4 — it just changes the x-callback-url prefix.

  1. Make two backups from LCP Settings -> Backups -> Back Up Now. One is a spare just to play it safe.
  2. Get the backup onto your computer, presumably through Dropbox.
  3. cd to the directory of the backup file, and python3 /path/to/lcp_export.py -read file.lcpbackup. Make note of the .json file it outputs.
  4. Use ack (or grep) to take a look at the actions in question: grep "drafts:" file.json.
  5. Use this perl regex to preview the changes: perl -ne 'if (s#\"drafts:(//|\")#\"x-drafts4:\1#g) { print "$ARGV\t"; print }' file.json . Compare with the grep output to make sure you’re changing all the URLs but none of the names or actions.
  6. If everything looks good, save the regex but get rid of the print statement and use perl pie instead to make the changes. perl -pi -e 's#\"drafts:(//|\")#\"x-drafts4:\1#g' file.json
  7. Verify the changes: grep "x-drafts4:" file.json
  8. Re-write the lcpbackup file: python3 /path/to/lcp_export.py -write file.json
  9. Load back into LCP. Settings -> Backups, pull to refresh, choose the _binary backup (should be the most recent one, top of the list).

All the commands together in a possibly more readable code section:

python3 /path/to/lcp_export.py -read file.lcpbackup
grep "drafts:" file.json
perl -ne 'if (s#\"drafts:(//|\")#\"x-drafts4:\1#g) { print "$ARGV\t"; print }' file.json
perl -pi -e 's#\"drafts:(//|\")#\"x-drafts4:\1#g' file.json
grep "x-drafts4:" file.json
python3 /path/to/lcp_export.py -write file.json

Seems to do the trick. Let me know in the comments section if you run into issues.