24

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
  • 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
  • 2
    That's really annoying when you actually have the right to copy phrases :'( – Rubens Mariuzzo Dec 30 '16 at 13:40
  • 1
    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
  • 1
    @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
6

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

In Automator, create a new Service 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

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.

  • 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 at 16:18
3

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!

  • Welcome to Ask Different! We're trying to find the best answers and those answers will provide supporting info as to why they're the best. Answers should be self-contained and just a link so others can find them by using the search feature. Links can change and become outdated so we prefer the answers to not just be a link. See How to Answer on how to provide a quality answer. – fsb Jul 28 '17 at 13:28
  • 1
    @fsb, Thank you very much for your suggestions. I heartily Appreciate it. I have updated my answer and Pls let me know if any changes required. Happy Coding...Thanks Again – Renish Dadhaniya Jul 29 '17 at 4:22
2

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

0

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”.

“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.*iBooks\.\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.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.