...But how are the names of the in Joomgallery imported pictures related to the original pictures? So how can I update the info with a script in the database?
during the upload the upload date and a 10-digit random number are appended to the filename.
You can see the new file names as well as the image title in the database table #__joomgallery.
You could also try the following solution:
A user once wrote an import script. You can find it here: https://github.com/fruwolt/csv2joom-dev
This also allows a larger number of images and categories to be imported and provided with the desired information via a csv file.