0

My question resembles the question by cadr, but with a major difference: I want to keep only lines that differ. So I want a structure

* a
** b
*** c
a
g
*** h
**** k
***** c
*** i
*** h
**** k
*** c
a
j

to become

* a
** b
*** c
a
g
j
*** h
**** k
***** c
*** i

So, one of the duplicate lines of the same headline on the same level is removed, different lines are merged.

UPD: Part of structure from my org file:

* laptops
** Toshiba Satellite A300
... some tasks
** Packard Bell
** Toshiba Tecra A8
... some tasks
** Toshiba Satellite A300
... some tasks, mostly duplicates to the upper ones
** Toshiba Tecra A8
... some tasks, mostly duplicates to the upper ones

I didn't find many examples, but hope that this piece of structure will clarify my usage. My org tree structure has some duplicates in it, because of moving structure parts here and there: to another org file or just to another parent. So when I place them to a common parent, I would like to merge them. For example, recursively delete the identical headlines on the same level.

So, it would be ideal to have the same functionality as a Firefox extension Bookmark Dupes has for Firefox bookmarks:

  1. It finds duplicates on all levels and asks which of them to remove.
  2. It can find and remove empty folders, that are possibly left after removing duplicates.

To remove all empty folders, you need to search and remove empty folders until nothing is found, that means to repeat step 2.

But that's what I'd like to have:

  1. Remove any of duplicate org items without children that are found on the same level elsewhere in the given structure.
  2. Repeat step 1 until there are no duplicate org items without children.
  3. Move all children to another structure on the same level with the same heading.
2
  • I come across many folks using org headngs as a list. I always wonder what the use case is. If you share your use-case--what you are trying to do in real-life, how you take notes etc--I will post a solution. Btw, you are NOT linking to a user question, but liking to a user page. So, I cannot see what that other user has asked.
    – user31220
    Jul 14, 2022 at 14:17
  • @whitetrillium I have provided clarification to my use case. Hope, it makes more sense now. I use org headings as a tree. Aug 25, 2022 at 11:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.