I've several wordpress sites and I'm using bulk media upload (my own script). But sometimes, for server issues or image issues, upload failing. I don't want to reupload these image but I don't want to they exist in my media gallery too. I've tried wordpress broken link checker plugin but it's working embedded medias in post but not in the embedded galleries. So, is there any way to check media files really exist and delete broken ones? Thanks.
You can use WP Image Editor to check, try:
$image = wp_get_image_editor( 'my_image.jpg' );
if (is_wp_error($image)){
//do some action, like add image path and name to array of broken images
}