Copy From Ibook

Author Avatar
Young Hug Aug 23, 2020

We know the content will be with from blabla when we try to copy the content from the IBook. And this is really inconvenient.

Solution

There are two solutions which have the same idea. Get the content of the clipboard, using script to change the content and paste.

Using the Automator.app

  1. New a quick action

  2. Add the Get Contents of Clipboard action(Library->Utilities-> Get contents of Clipboard)

  3. Add the Run ShellScript and add

    1
    sed -E -e 's/^“//g' | sed -E -e 's/”([ ]|$)//g' | sed -E -e '/^$/d' | sed -E -e 's/(摘录来自|Excerpt From).*//g'

    image-20200823144209472

Note:
The sed has a bit different between MAC and Linux.

  1. Enable the workflow and set a hotkey(System->keyBoard->shortcuts->services->General)

Using Alfred

  1. add a new workflow and using the Paste as plain text from hotkey template(plus icon -> Templates->Clopboard->Paste as plain text from hotkey)

  2. insert an Run Script action after Hotkey(right click->Insert After->Actions->Run Script) and add the script:

    1
    2
    3
    query=$1

    echo -n $query | sed -E -e 's/^“//g' | sed -E -e 's/”([ ]|$)//g' | sed -E -e '/^$/d' | sed -E -e 's/(摘录来自|Excerpt From).*//g'

    image-20200823152502922

Usage

Using the hotkey which you have stetted after you copy words in Ibook.app.

Enjoy! 🎆️

This blog is under a CC BY-NC-SA 3.0 Unported License
Link to this article: https://younggod.netlify.app/2020/08/23/practice/CopyFromIBook/