Zen Cart Logo
Forums / All Other Contributions/Addons / filtering out missing images

filtering out missing images

Views: 1,024

Results 1 to 6 of 6
9 Aug 2013, 1:39 PM
#1
alibaba99 avatar

alibaba99

New Zenner

Join Date:
Mar 2011
Location:
guernsey , uk
Posts:
39
Plugin Contributions:
0

filtering out missing images

my website is quite large, and I have a backup of all csv and image files on my computer

as I have over 100,000 products and my intention is to filter the list onto separate website so that each site carries a different category

my problem comes when I upload the csv files, and the images, some of the images seem to be missing, but to go through 100,000 product lines would be a nightmare.

I had a good excel programmer friend help me out one time, with the following batch file, which was of enormous help, and probably will be for anyone else wanting to filter out images from a huge folder, based on those inside a text file

is there anyone who can take this a step further, and have the batch file dump a list of the filenames it was not able to find, into a separate file?

batch.bat file is

@echo off & setlocal
:: assuming this is where they are, if not, adjust as needed:
set location=C:\Users\Windows7\Desktop\iwantafiles\fullcsvfiles\categories\mobiles\images
for /f "tokens=*" %%a in (%location%\imagelist.txt) do (
copy "%location%\%%a" c:\imagelist
)
::end batchscript
9 Aug 2013, 11:53 PM
#3
alibaba99 avatar

alibaba99

New Zenner

Join Date:
Mar 2011
Location:
guernsey , uk
Posts:
39
Plugin Contributions:
0

Re: filtering out missing images

nice suggestion, but it is the opposite of what this cron does, I don't want to delete unused images from my server, I want to find out which products do not have an image assigned to them

10 Aug 2013, 12:08 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: filtering out missing images

Try this instead:

Paste the following code into a new file (find_missing_images.php) in the root of your store (same folder as ipn_main_handler.php):```

<?php $_SERVER['REMOTE_ADDR'] = 'cron'; $result = require('includes/application_top.php'); if ($result == FALSE) die("Error: application_top not found.\nCannot proceed.\n\n"); $result = $db->Execute( "SELECT products_id, products_status, products_image FROM " . TABLE_PRODUCTS . " ORDER BY products_image" ); $missing = array (); while (!$result->EOF) { if (!file_exists(DIR_WS_IMAGES . $result->fields['products_image'])) $missing[] = $result->fields['products_image']; $result->MoveNext(); } if (sizeof($missing)) { echo '<p>Missing images identified:</p>' . "\n"; foreach($missing as $val) { echo $val . "<br>\n"; } } else { echo '<p>No missing images identified.</p>'; } ```And then access it via your browser: <https://www.example.com/find_missing_images.php>
16 Aug 2013, 10:19 AM
#5
alibaba99 avatar

alibaba99

New Zenner

Join Date:
Mar 2011
Location:
guernsey , uk
Posts:
39
Plugin Contributions:
0

Re: filtering out missing images

works well, thanks for this

now to challenge you even more - is there a add on where the products listed on my cart, which have the missing images, can be remoled in bulk?

27 Apr 2014, 10:18 PM
#6
bikerstuff avatar

bikerstuff

New Zenner

Join Date:
Apr 2014
Posts:
80
Plugin Contributions:
0

Re: filtering out missing images

I tried the code listed.

I have about 800 items and only about 20 have an image so for, New Store I'm just setting up.
I got a message "No missing images identified." and I guess that is because the products do not yet have an image specified.

Is there a similar easy way to find what items do not yet have a picture? I have about 2,000 items to do total eventually.

Also how do I bulk upload my images and get the products to find them. I am sure I am missing something easy?
At this time I am trying to go through 1 item at a time and enter the image. Images have the same name as item number. So if myproduct123 is the item number then the image is myproduct123_400.jpg
I have read that if I used a base name such as myproduct.jpg Zencart would use all images of that base such as myproduct123_400.jpg and myproduct123_400BK.jpg etc.. for extra images, but that is not working either for me right now. I use myproduct123.jpg and the image is not shown, it is only shown when I use the full name myproduct123_400.jpg

I can bulk upload all the images into /images but do I really have to go through each item one at a time in category/products to add them?

Thanks