# undisputed FrontEndTokenExecute

Thanks to this great topic, I've found the FrontEndToken that I was looking for: "DeleteGeneratedCells" (well, it is also written in Help but I've found it later :)

Question: I would love to execute it in NotebookObject without confirmation through the automatically displayed ChoiceDialog["Do You really want to..."].

Is it maybe a case of FrontEndTokenExecute parameters?

I suspect I can deal with it by setting some global options for Mathematica but I would rather leave them.

-
Related, perhaps duplicate: How to automate a FrontEnd return? – István Zachar Sep 12 '13 at 11:52
@IstvánZachar I would say it is very closely related because our purposes are a bit little different and acceptable solutions too. But we will see what community decides ;) – Kuba Sep 12 '13 at 11:55

Maybe you are looking for something like this. Make a list of the generated cells like this:

cells = Cells[GeneratedCell -> True];


Then delete them from the notebook using this

NotebookDelete[cells];

-
I had to check but it seems that for my needs this works well. And there is no ChoiceDialog[] so thank You for this answer :) – Kuba May 21 '13 at 18:16
@Kuba no problem, glad you like it :) – Jacob Akkerboom May 21 '13 at 18:17
I'm very happy to see answers using the under-utilized Cells function. But I'm not sure what you mean by your statement that this "doesn't use the front end". Both Cells and NotebookDelete require a front end to work properly, and they're implemented by causing the kernel to issue commands to the front end. Incidentally, code very similar to this is in the Applications Examples section of the Cells documentation. – John Fultz Sep 12 '13 at 5:48
@JohnFultz ah, yes, I have made this mistake in another Q&A as well, and fortunately there I was immediately corrected. I should have remembered this Q&A. Thank you – Jacob Akkerboom Sep 12 '13 at 10:00