Delete all children bookmarks

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Loki@99
User
Posts: 558
Joined: Sat Dec 16, 2023 11:09 am

Delete all children bookmarks

Post by Loki@99 »

Hi,

There's an option to Delete but Retain Children bookmark but I can't find a Delete all children bookmarks feature.

Looking for the opposite of that feature
image.png

Is this not yet supported ?

Edit : I noticed that it was requested a long time ago in this post so it's not supported

Thanks for considering this,
You do not have the required permissions to view the files attached to this post.
Major Stylus topics
- RemoveAnnotationsWithEraser T#6903
- MiniPopupMenuOnTextSelection T#6894
- AbnormalSpikes forum.pdf-xchange.com/viewtopic.php?p=179935&hilit=spikes#p179935
- ForceEraserPreview forum.pdf-xchange.com/viewtopic.php?t=42380
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7360
Joined: Wed Mar 25, 2009 10:37 pm

Re: Delete all children bookmarks

Post by Paul - PDF-XChange »

Hi, Loki@99

It's just "delete". That deletes the bookmark and it's children.

There is no option for delete just the children.

Can you not simply select those children and delete of you want to retain the parent?
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
Loki@99
User
Posts: 558
Joined: Sat Dec 16, 2023 11:09 am

Re: Delete all children bookmarks

Post by Loki@99 »

Hi Paul,
Paul - Tracker Supp wrote: Mon Sep 23, 2024 8:40 pm Can you not simply select those children and delete of you want to retain the parent?

The issue is that there are too many children that I want to delete while retaining the parent so it will be very time consuming. Especially with my 12.6 inch device.

For e.g, I would like to delete all level 3 "Question" bookmark in the following file.
Sample.pdf
As you can see in the following GIF, there are many "Question" bookmark

GIF
issue.gif

Having a feature for deleting children bookmarks will drastically speed up the process.

Like this
image.png
You do not have the required permissions to view the files attached to this post.
Major Stylus topics
- RemoveAnnotationsWithEraser T#6903
- MiniPopupMenuOnTextSelection T#6894
- AbnormalSpikes forum.pdf-xchange.com/viewtopic.php?p=179935&hilit=spikes#p179935
- ForceEraserPreview forum.pdf-xchange.com/viewtopic.php?t=42380
User avatar
rakunavi
User
Posts: 1673
Joined: Sat Sep 11, 2021 5:04 am

Re: Delete all children bookmarks

Post by rakunavi »

Hello Loki@99,

Not the direct way you are looking for, but it would be easiest to export the bookmarks once to a text file, open it in a text editor that can handle regular expressions, bulk replace the parts you want to delete, and import it again in the PDF-XChange Editor.

  • Animation.gif
In the video, I started with all settings initialized, so it took 35 seconds, but it should be shorter once you get used to it.

Another way, again not the one you are looking for, is to use JavaScript to remove it. It is less flexible than the method using a text editor, but can be deleted in an instant.

Code: Select all

function deleteBookmarks(bm, level) {
    if (bm.children != null) {
        for (var i = bm.children.length - 1; i >= 0; i--) {
            deleteBookmarks(bm.children[i], level + 1);
        }
    }
    if (level == 4) {
        bm.remove();
    }
}

for (var i = 0; i < this.bookmarkRoot.children.length; i++) {
    deleteBookmarks(this.bookmarkRoot.children[i], 1);
}
Best regards,
rakunavi
You do not have the required permissions to view the files attached to this post.
TOP desires for PDFXCE
forum.pdf-xchange.com/viewtopic.php?t=39665 LassoTool
forum.pdf-xchange.com/viewtopic.php?t=38554 CmtGarbled
forum.pdf-xchange.com/viewtopic.php?t=37353 FulScrMultiMon
forum.pdf-xchange.com/viewtopic.php?t=41002 DisableTouchSelect
Loki@99
User
Posts: 558
Joined: Sat Dec 16, 2023 11:09 am

Re: Delete all children bookmarks

Post by Loki@99 »

Hi

@rakunavi

Thank you for your help. Your tips indeed work but it's a bit too technical for me as I'm not fluent with those regular expressions and JavaScript stuff.

The issue is that I have many other files which I need to delete children bookmarks.

I hope that Tracker Support will take a look at this as @Sasha said in the old post.
Sasha - Tracker Dev Team wrote: Thu May 02, 2019 8:53 am This is a reasonable suggestion - we'll try to add such a command that will remove children of the selected bookmarks.
If a Delete but retain children feature exists, it would make sense that the opposite feature Delete children only existsa as well.
Major Stylus topics
- RemoveAnnotationsWithEraser T#6903
- MiniPopupMenuOnTextSelection T#6894
- AbnormalSpikes forum.pdf-xchange.com/viewtopic.php?p=179935&hilit=spikes#p179935
- ForceEraserPreview forum.pdf-xchange.com/viewtopic.php?t=42380
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11031
Joined: Wed Jan 03, 2018 6:52 pm

Re: Delete all children bookmarks

Post by Daniel - PDF-XChange »

Hello, Loki@99

I have followed up with Sasha about this to see what happened with that task. If a new ticket ends up made, I will post that here.

RT#7123: FR: Add "Delete All Children bookmarks" function.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Mathew
User
Posts: 571
Joined: Thu Jun 19, 2014 7:30 pm

Re: Delete all children bookmarks

Post by Mathew »

In the mean time, here's a tool I made to delete bookmark children.

Extract the zip file and save in the Javascripts folder. On restart, it will add a button to the bookmarks toolbar:
image.png
bkmDeleteChild v0.2.zip

It opens a dialog listing all the current bookmarks:
image(1).png
If you select a parent bookmark, and press the [Delete] button in the lower left corner, it will mark the children of that bookmark for deletion.
image(2).png
When you are done picking bookmark children to delete, press OK. Nothing is actually deleted until you press OK - so if you cancel, everything is left unharmed.
You do not have the required permissions to view the files attached to this post.
Loki@99
User
Posts: 558
Joined: Sat Dec 16, 2023 11:09 am

Re: Delete all children bookmarks

Post by Loki@99 »

Mathew wrote: Thu Sep 26, 2024 5:24 am In the mean time, here's a tool I made to delete bookmark children.
Hi Mathew,

Thanks for making that great tool.

Is it possible that you add a collapse-expand feature inside so that there's no need to scroll through all bookmarks ? I sometimes deal with +2000 bookmarks. A multiple selection feature will be great as well.

GIF
Issue - No expand or collapse
no expand-collapse.gif

I also noticed that it always redirects to the first bookmark after clicking "Delete" which reduces productivity

GIF - Clicking "Delete" always redirect to the first bookmark
test.gif

Thank you,
You do not have the required permissions to view the files attached to this post.
Major Stylus topics
- RemoveAnnotationsWithEraser T#6903
- MiniPopupMenuOnTextSelection T#6894
- AbnormalSpikes forum.pdf-xchange.com/viewtopic.php?p=179935&hilit=spikes#p179935
- ForceEraserPreview forum.pdf-xchange.com/viewtopic.php?t=42380
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11031
Joined: Wed Jan 03, 2018 6:52 pm

Re: Delete all children bookmarks

Post by Daniel - PDF-XChange »

Hello, Loki@99

Just a quick followup, A ticket has been made, so we can expect this feature in the future:

RT#7123: FR: Add "Delete All Children bookmarks" function.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Mathew
User
Posts: 571
Joined: Thu Jun 19, 2014 7:30 pm

Re: Delete all children bookmarks

Post by Mathew »

Loki@99 wrote: Thu Sep 26, 2024 5:39 am Is it possible that you add a collapse-expand feature inside so that there's no need to scroll through all bookmarks ? I sometimes deal with +2000 bookmarks. A multiple selection feature will be great as well.

I also noticed that it always redirects to the first bookmark after clicking "Delete" which reduces productivity
OK, try this version: I added the ability to expand/collapse the bookmarks. There are two problems with the dialog that javascript can make:
  1. I don't think there's a built-in way to do multiple selections in a list_box. I made a rudimentary version: (select the first row, then the check box at the bottom of the dialog, then it will select all rows between that first row and whichever row you select next). The problem is that in order to change how the selected row looks, it will scroll back up to the top each time you change the multiple selection... It marks the selected rows with [ square brackets ]. I've found that using the up/down arrow keys may be easier... Once you have all the rows you want selected, press "Delete" and it will apply to all of them.
    image.png
  2. Every time javascript changes the contents of the list_box, it resets to the top, even though the selection is way down the list. Would be nice to be able to get/set scroll position, or at least for PXE to remember the last position...
bkmDeleteChild v0.3.zip
Oh, I added a machine translation for French ... let me know if some of the words are wrong:

Code: Select all

 "FRA": {
     "Delete Children": "Supprimer Enfants",
     " [%1 children to delete]": [" [%1 enfant à supprimer]"," [%1 enfants à supprimer]"],
     "Delete Child Bookmarks": "Supprimer les signets enfants",
     "Select bookmark and press [Delete] to delete children:": "Sélectionnez le signet et appuyez sur [Supprimer] pour supprimer les enfants :",
     "Expand All": "Développer Tout",
     "Collapse All": "Réduire Tout",
     "Expand/Collapse": "Développer/Réduire",
     "Delete": "Supprimer",
     "Select Range": "Sélectionnez Plusieurs",
     "There are no bookmarks!": "Il n'y a pas de signets !",
     "User cancelled": "Utilisateur annulé"
 }
You do not have the required permissions to view the files attached to this post.
Loki@99
User
Posts: 558
Joined: Sat Dec 16, 2023 11:09 am

Re: Delete all children bookmarks

Post by Loki@99 »

Hi all,
Mathew wrote: Thu Sep 26, 2024 9:34 pm OK, try this version: I added the ability to expand/collapse the bookmarks.
@Mathew Thanks for the tool update. Expand/collapse feature and the range selection work as intended. I don't have PDFXCE interface language set to french but thanks for the translation.

TrackerSupp-Daniel wrote: Thu Sep 26, 2024 3:28 pm Just a quick followup, A ticket has been made, so we can expect this feature in the future:

RT#7123: FR: Add "Delete All Children bookmarks" function.
@Daniel

Thanks the the ticket.

Looking forward for PDFXCE native feature,

Kind regards,
Major Stylus topics
- RemoveAnnotationsWithEraser T#6903
- MiniPopupMenuOnTextSelection T#6894
- AbnormalSpikes forum.pdf-xchange.com/viewtopic.php?p=179935&hilit=spikes#p179935
- ForceEraserPreview forum.pdf-xchange.com/viewtopic.php?t=42380
Loki@99
User
Posts: 558
Joined: Sat Dec 16, 2023 11:09 am

Re: Delete all children bookmarks

Post by Loki@99 »

Hi,

For some reason, the script doesn't work when deleting the following range with this file
File bookmark delete issue.pdf
Select range Item 302 to Item 350 in Entraînement > Vignettes cliniques > Enoncés et questions

GIF
issue.gif

As you can see, bookmarks child are still there
image.png

Thanks for investigating,
You do not have the required permissions to view the files attached to this post.
Major Stylus topics
- RemoveAnnotationsWithEraser T#6903
- MiniPopupMenuOnTextSelection T#6894
- AbnormalSpikes forum.pdf-xchange.com/viewtopic.php?p=179935&hilit=spikes#p179935
- ForceEraserPreview forum.pdf-xchange.com/viewtopic.php?t=42380
Mathew
User
Posts: 571
Joined: Thu Jun 19, 2014 7:30 pm

Re: Delete all children bookmarks

Post by Mathew »

Loki@99 wrote: Fri Sep 27, 2024 8:18 pm For some reason, the script doesn't work when deleting the following range with this file
@Loki@99 I think I found the bug and squashed it in v0.4 below. Thanks for the help and sample file.
**Edit** I found another bug in displaying multiple bookmarks with the same name. I don't think anyone downloaded yet, so here's v0.4.1
bkmDeleteChild v0.4.1.zip
I've also added a workaround for the way it keeps scrolling back up to the top - but it's a bit weird. I've turned it off on the one I use because I can't get used to not using the scroll wheel, but it does make deleting multiple rows less frustrating.

There are some settings that you can change on lines 34-38.
  • Set line 34 to the maximum number of lines to show at a time. I've set it to 20. If you set it to 0 then it will just use regular scrolling
  • Set line 35 to false to leave all bookmarks expanded when you open the dialog
  • Lines 36-38 are the spacers used on the front to indent child bookmarks, and show whether they are open or closed
:

Code: Select all

33    const dcbPrefs = {
34        listboxMaxlen: 20, // set to 0 to use scrolling
35        openCollapsed: true, // set to true to open the dialog with all bookmarks collapsed
36        pSpace: "    ", // to space out lower levels in list box
37        pOpen: "\u02C5 ", // mark for open parent \u25BC
38        pClose: "> ", // mark for closed parent \u25BA
39    };
If using paging, then the dialog will look like this:
image.png
At the top of the listing of bookmarks, it says which rows it's displaying and the total number, with up and down arrows to scroll through the 'pages' of bookmarks. If you have "Select range" checked while scrolling up and down, it will continue selecting all the rows as you switch pages.
You do not have the required permissions to view the files attached to this post.
Loki@99
User
Posts: 558
Joined: Sat Dec 16, 2023 11:09 am

Re: Delete all children bookmarks

Post by Loki@99 »

Hi Mathew,
Mathew wrote: Sat Sep 28, 2024 12:35 am @Loki@99 I think I found the bug and squashed it in v0.4 below. Thanks for the help and sample file.
**Edit** I found another bug in displaying multiple bookmarks with the same name. I don't think anyone downloaded yet, so here's v0.4.1
I've also added a workaround for the way it keeps scrolling back up to the top - but it's a bit weird. I've turned it off on the one I use because I can't get used to not using the scroll wheel, but it does make deleting multiple rows less frustrating.
You're welcome. Thanks for updating the script.

I can confirm that the bookmarks range issue I reported is fixed in 0.4.1.

I also disabled your workaround for the scrolling back up to the top issue as I scroll with a touchscreen device.
Major Stylus topics
- RemoveAnnotationsWithEraser T#6903
- MiniPopupMenuOnTextSelection T#6894
- AbnormalSpikes forum.pdf-xchange.com/viewtopic.php?p=179935&hilit=spikes#p179935
- ForceEraserPreview forum.pdf-xchange.com/viewtopic.php?t=42380
User avatar
Dimitar - PDF-XChange
Site Admin
Posts: 2207
Joined: Mon Jan 15, 2018 9:01 am

Delete all children bookmarks

Post by Dimitar - PDF-XChange »

:)
Mathew
User
Posts: 571
Joined: Thu Jun 19, 2014 7:30 pm

Re: Delete all children bookmarks

Post by Mathew »

This tool is no longer needed as of (at least) Build 393, so if you have a recent version, it's better to just delete bkmDeleteChild.js from the Javascripts folder. But I ran into an issue where if this script was still installed, it was causing problems with other scripts if they did not have 1ang.js installed. So I've made a fixed version below:
bkmDeleteChild v0.5.zip
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11031
Joined: Wed Jan 03, 2018 6:52 pm

Delete all children bookmarks

Post by Daniel - PDF-XChange »

:)
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com