The script from @femkeblanco works exactly as you described. Unfortunately, you forgot to mention that there are dozens of nested clipping groups in your file and furthermore compound path items in some groups exists.
It might also be helpful to specify the correct Illustrator version. Because not every helper here in the forum always uses the latest version.