I just want to keep only some of the pages (two folders) and hopefully just the images that are used there. Especially with getting rid of the (far too many) images that not used I could not find another way of doing it.
Depending on how you are porting it over you may end up with new UIDs for the images. Like, if you have a script that is programmatically recreating these images in the new location instead of actually copying the db over, they will have new UIDs. So you may need to make some mapping of UID->path from the old database and use that to get the new UID from the path for the new location. But you definitely want to use UIDs to link to the images.
Side note, when you create an internal link in the wysiwyg it will save it as src="resolveuid/097622a974a2943d177bda0792f0af75" or something like that. You don't normally actually see a link that looks like this when viewing the page, because of a transform that happens under the hood. If you mouse over the link in the view page you will see that the link looks like "/path/folder/imagexx.jpg" or something instead. But that's just some prettiness on the surface, it's not actually save that way. It's saved based on UID because that's the only way to do link integrity.