44

I read on iBooks, and some other resources and gather my notes in EverNote. When I copy a text from iBooks to keep it as a note in some other external application like EverNote, it keeps pasting the source info which is so annoying and I have to keep deleting them after every copy-paste. For example:

“To bind this class using Ninject, I specify the value of the constructor parameter using the WithConstructorArgument method in the AddBindings method, as shown in Listing 6-20.”

Excerpt From: Adam Freeman. “Pro ASP.NET MVC 5.” iBooks. https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewBook?id=4CB3769B56E7D2A905C0332D53D7E31D
5
  • 2
    You can't avoid this. Apple programmed it that way due to legal and copyright. So bad news for you need to get used to it. :-( – konqui Jul 5 '14 at 6:15
  • may you can build a Automator Script - but I'm not sure if you can edit Text Copy+Paste Process ... – bMalum Jul 5 '14 at 9:19
  • 3
    That's really annoying when you actually have the right to copy phrases :'( – Rubens Mariuzzo Dec 30 '16 at 13:40
  • 2
    Came here because pasting from the Swift book examples sucks. One more reason to get literature from iBooks but all programming books on Kindle. – Dirk Bester Feb 23 '17 at 18:45
  • 3
    @konqui They know we can delete that right. It is not very clever. It is an annoying boilerplate for a basic task. – atilkan Mar 17 '17 at 6:39
29

Here is a solution that requires no third-party software and lets you keep using the standard C shortcut to copy text in Books.

1. Create a Quick Action “Copy without Citation in Books”

  1. Open Automator and choose File > New (N).
  2. For the type of document, choose Quick Action. This will allow us to create a keyboard shortcut for it later.

    Choose Quick Action as the type of document in Automator

  3. Configure the workflow as follows:

    • Workflow settings

      • Workflow receives current [text] in [Books]
      • (Leave the other three settings at the default)
    • Add in the actions list:

      1. Copy to Clipboard

    contents of the Automator workflow

  4. Use S to save the Quick Action. Name it “Copy without Citation in Books”.

The “workflow receives current text in Books” setting in the workflow bypasses the clipboard-modifying behavior of Books. Thus, the workflow needs no extra action to strip the text added by Books.

2. Give the Quick Action a keyboard shortcut of C in Books

  1. Open System Preferences > Keyboard. View the Shortcuts tab and select App Shortcuts on the left.
  2. Click the + button to add a new App Shortcut.
  3. Fill in the sheet as follows:

    • Application: Books
    • Menu Title: Copy without Citation in Books
    • Keyboard Shortcut: C

    Adding an App Shortcut for “Copy without Citation in Books”

  4. Click Add. You will see the shortcut appear in the list:

    App Shortcuts: “Copy without Citation in Books” is mapped to ⌘C in Books

And you’re done. From now on, when you want to copy your selected text in Books, just press C and the exact text will be copied.

10
  • Thanks to stassats in this Hacker News comment for the idea to use “workflow receives current text in Books” to bypass Books’s clipboard modification. – Rory O'Kane Feb 20 '20 at 4:47
  • OMG this is such a jewel! If I could upvote by 10 votes I would right now. I am so tired of removing those stupid oddly formatted attribution lines. Sigh of relief! – Rich Apr 22 '20 at 9:35
  • Amazing guide, thank you very much! This should be the accepted answer. – ayanami May 1 '20 at 13:59
  • 1
    @freennnn To copy without text formatting, the first solution that comes to my mind is using the free app Plain Clip to strip the formatting after copying. To make the Automator action do this automatically: 1. Install Plain Clip (by dragging the app in the DMG to Applications). 2. In the Automator workflow, after the “Copy to Clipboard” action, add a “Launch Application” action and choose Plain Clip as the application. – Rory O'Kane May 16 '20 at 7:08
  • 1
    Setting to Cmd-C didn’t work (still used the regular copy action), but Cmd-Shift-C did. – Yatharth Agarwal Mar 20 at 22:46
15

This blog post gives an example of how to do it using an Automator script with a keyboard shortcut.

In Automator, create a new Quick Action that receives no input. Give it these three actions:

  1. Get Contents of Clipboard
  2. Run Shell Script
  3. Copy to Clipboard

Put this in the Run Shell Script action:

# strip out iBooks citation
sed -E -e 's/^[ ]?[0-9]* //g' | sed -E -e 's/“[ ]?[0-9]?[ ]?//g' | sed -E -e 's/”$//g'  | sed -E -e 's/^(Excerpt From).*//g'

“Remove iBooks citation” service in Automator

After saving the service, you can assign a shortcut to this action, such as I, in System Preferences > Keyboard > Shortcuts > Services. Then you hit that shortcut before you paste if you want to get rid of the text that iBooks added.

4
  • Thanks Amir, super helpful, this has been bugging me for ages! – GGx Jun 14 '19 at 14:41
  • Isn't that really really really problematic? What happens if there's a regex match for some other thing you copy pasted? – Tom Granot Aug 14 '19 at 19:50
  • 1
    @t0mgs then you simply don't use the assigned shortcut before pasting – Martin Oct 26 '19 at 5:10
  • Legitimate i suppose. Thanks! – Tom Granot Oct 26 '19 at 6:40
5

You could use Keyboard Maestro to trigger the following AppleScript:

set original_clipboard to the clipboard
set paragraph_count to count of paragraphs of original_clipboard
-- assuming the last two paragraphs are what you want to strip out--
-- that is, the blank line and the attribution
set new_clipboard to paragraphs 1 thru -2 of original_clipboard as string
set the clipboard to new_clipboard
-- now you can paste

With Keyboard Maestro you would make a new macro, triggered by some keystroke (maybe Command-Option-V), and the first step would be an "Execute an AppleScript" (in the Execute section) using the above script. The next step would be a "Paste" (in the Clipboard section). You would copy your text, then click where you want to paste it, then press Command-Option-V to have it pasted in without the last two paragraphs.

Other macro programs would work too as long as they know how to execute an AppleScript.

5
  • I used your solution, but the final result is including quotation mark. How do I get rid of that so that the surrounding quotation marks are removed? – Michael Jaq Oct 29 '18 at 2:32
  • You shouldn't even need an external program—put the AppleScript into an automator service, then set the automator service to a keyboard shortcut. – Wowfunhappy Oct 29 '18 at 3:32
  • @MichaelJaq My answer contains a macro for Keyboard Maestro that strips the quotation marks too. – Rory O'Kane Mar 17 '19 at 16:18
  • @MichaelJaq you can use this method with the shell script in this thread and it will remove the quotation. Change "Execute an AppleScript" to "Execute Shell Script". This AppleScript didn't remove them so only a partial result. – MarkBTomlinson Jun 30 '19 at 11:00
  • Here's my version of this script that cleans up the quotes as well github.com/robenkleene/AppleScripts/blob/… – robenkleene Feb 29 '20 at 20:00
4

Below are steps for copying text from iBooks:

  1. Highlight the passages you wish to copy.
  2. A popup will be opened automatically or you must open a popup using a right click on selected passages.
  3. Select the 'Add Note' option from the popup.
  4. The selected/highlighted text will be shown on the left pane.
  5. Right click on the passages in the left panel and select the 'Copy' option.

I have created a video to show how it works: https://youtu.be/ZQLl_Gl9TMw

Happy coding!

1
  • > The selected/highlighted text will be shown on the left pane. What left pane? This is wrong. No any left pane exsts – Green Sep 20 '19 at 11:38
3

I have created a script for ClipMenu (macOS clipboard utility) to strip unwanted information:

return clipText.replace(/^“/, '').replace(/”\s*Excerpt.*iBooks\.\s?$/, '');

Save as /Users/USERNAME/Library/Application Support/ClipMenu/script/action/iBooks.js

3

Here is how to set up a Keyboard Maestro macro to strip the extra text, including the quotation marks, the moment the text is copied from iBooks.

First, create a macro group called “iBooks-specific mapping” and add iBooks within “Available in these applications”. (In more recent macOS versions, the application will be named Books instead of iBooks.)

“iBooks-specific mapping” group in Keyboard Maestro

Then create a macro named “Copy Without Citation”. Assign it the hot key C. Give the macro the following actions:

  1. Clipboard > Copy
  2. Clipboard > Search and Replace
    • Search: System Clipboard
    • for: Regular Expression (case sensitive)
      • ^“
    • and replace with:
      • (leave empty)
  3. Clipboard > Search and Replace
    • Search: System Clipboard
    • for: Regular Expression (case sensitive)
      • ”\s*Excerpt.*Books\.\s?$
    • and replace with:
      • (leave empty)

This is how it will look in Keyboard Maestro:

“Copy Without Citation” macro in Keyboard Maestro

Now any text in iBooks copied using that keyboard shortcut will have the extra text stripped from both ends.

3
  • Thanks to Filip Suk’s answer for the regular expressions. – Rory O'Kane Mar 17 '19 at 16:20
  • For those whose iBooks was replaced by "Books", just modify the last RegEx with ”\s*Excerpt.*Books\.\s?$ – Tim N. Oct 15 '19 at 1:14
  • @TimN. Thanks. I updated the answer and screenshots to use that regex, since that regex should work for both app names. – Rory O'Kane Oct 17 '19 at 21:34
2

from Amir Raminfar's answer. this is a way if you want copy directly without Command C to save content to clip board.

just change Workflow receives current to: "text" in "Books.app" and disable get contents of Clipboard.

1
  • Welcome to Ask Different. This is a comment on a previous Answer and not a stand-alone Answer. It shouldn't be it's own Answer. Please see How to Answer for tips on providing answers here. - From Review – fsb Jul 8 '19 at 18:54
1

An altogether different approach is to abandon iBooks (/Books) and use a different eReader. Having spent a long time failing to implement several of the above solutions, I think it is a valid alternate to choose an eReader that does not pollute the clipboard contents with the citation, curly quotes and invisible control characters. My suggestion to you is Calibre. Calibre's main purpose is to convert between book formats, but it has a competent viewer which has all the features you get on the Apple product, albeit not as beautifully presented.

https://www.calibre-ebook.com/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .