If you use WordPress' sideload feature, you can do this more easily (and have WordPress handle all of the sanitization for you).
$desc = 'some description';
$file = 'http://www.example.com/image.png';
$file_array = [ 'name' => wp_basename( $file ), 'tmp_name' => download_url( $file ) ];
// If error storing temporarily, return the error.
if ( ...
Sorry this isn't a full answer, but yes this probably is possible but you need to run a database query or some code to find the images, and then do something with that list such as copy the files to a new directory.
There's info here on how featured images are stored.
Here's a quick suggestion based on that post, written as pseudocode, but if it's what you ...