Scenario: I have 9000 image files. 2400 of them are not being used.
How to find them and remove them quickly and safely
What this script does:
* Read the database and report back a list of installed images
* Mark (in RED) any DB listed image which does not exist on the server
* Read the server images and report back a list
* Compare the lists for missing data
* Offer you the ability to check or uncheck listed images controlling what gets renamed
* Rename the USER checked listed images from myimage.jpg to UNUSED_myimage.jpg
* Allow you to ftp and delete ALL renamed UNUSED_myimage.jpg images
Legend: 
Download

Report
Modified, so rather than specify subfolders to include, you now specify an exluded list, otherwise all sub-folders of 'images' are checked
(non-recursive). However the subfolder check is 'off' by default, enable on line 54
Added option for product links for 'not-found' images, this will not include images 'not-found' within product descriptions or any extra tables checked. This opion is 'off' by default, see line 51.
Support thread at http://forums.oscommerce.com/index.php?showtopic=343935 .
tested on PHP 4 & 5, SQL 4 & 5, osC 2.2 ms2, rc1 & rc2a and is register_globals compatible
FULL PACKAGE
Cleaned up and re-arranged the code to reduce query counts (and memory use)
Added new array for extra tables to make it easy to add extra tables into the mix (see 80 - 84 of file)
Support thread at http://forums.oscommerce.com/index.php?showtopic=343935 as couldn't find one.
tested on PHP 4 & 5, SQL 4 & 5, osC 2.2 ms2, rc1 & rc2a and is register_globals compatible
FULL PACKAGE
Added reading of category images
Added reading of manufaucturer images
Added option to check product description (default action) as many have html descriptions with images.
Added reading for some system files to check for images (default is header.php, index.php & stylesheet.css)
Added option to remove files from list by pattern match (ie thumbnails).
Removed some invalid html code
Modified to take image dir from configure.php
Corrected links so session wont be lost (could have caused failure of operation before &/or chuck you from admin)
Modified to move images to 'UNUSED' directory rather than renaming, means backup not needed and easier to revert. If files are in a sub-directory they will be moved to a sub-directory of 'UNUSED' with the same name.
Started support thread at http://forums.oscommerce.com/index.php?showtopic=343935 as couldn't find one.
tested on PHP 4 & 5, SQL 4 & 5, osC 2.2 ms2, rc1 & rc2a and is register_globals compatible
FULL PACKAGE
removed by default the png and gif support
switch bak to osc standart one image product query
1.2 by azer :
moved this history into this readme text file instead of contributions file
added back some bacgrounf on columns background bgcolor="#F5F5F5"
commented gif reports since it give a lot of infos on image type few people use for products photos
changed server variable to get them from configure.php variable
folowed the osc php file layout and call the js + html code on the proper section
changed the query to hide by default the product that are inactive
TODO: have a switch to show inactive , and out of stock or all products
TODO : have a switch to select wich extensions to show
TODO : "The total number of images on the server are" is wrong if the images are in subfolders
This version lists the files from the database etc for you to see which ones are in use.
I've just got rid of 16000 unused product images and kept the 4000 that I needed.
I've made many of the mod's discussed in the forum (such as the #UNUSED_ prefix, to list the files first in FTP - and removing the surplus "/admin/" links that break the various buttons).
I've just got rid of 16000 unused product images and kept the 4000 that I needed.
I've made many of the mod's discussed in the forum (such as the #UNUSED_ prefix, to list the files first in FTP - and removing the surplus "/admin/" links that break the various buttons).
At present when you click any of the two buttons:
'Check All Boxes' and 'Uncheck All Boxes' this URL is displayed.
http://www.yoursite.com/catalog/admin/admin/remove_unused_images.php#button
I have fixed this small error by replacing in the following code in line 330 (remove_unused_images.php):
### FIND ###
$msg .= "<a name=button></a><a name=end></a><br><div align=center><a href="admin/remove_unused_images.php#button" onClick="select_all('checked_unused_images', '1');"><font size=2><b>Check All Boxes</b></font></a><font size=2> | </font><a href="admin/remove_unused_images.php#button" onClick="select_all('checked_unused_images', '0');"><font size=2><b>Uncheck All Boxes</b></font>
### REPLACE WITH ###
$msg .= "<a name=button></a><a name=end></a><br><div align=center><a href="remove_unused_images.php#button" onClick="select_all('checked_unused_images', '1');"><font size=2><b>Check All Boxes</b></font></a><font size=2> | </font><a href="remove_unused_images.php#button" onClick="select_all('checked_unused_images', '0');"><font size=2><b>Uncheck All Boxes</b></font>
### ###
I have also made a slight change to the description in the SETTINGS section so that it's a little more easier to understand.
The final change I have made is to the 'readme.txt' file and have added "Step 6" in the installation category informing other users how to correctly configure their settings with this add-on.
Other than that however this is the work of the orginal author - 'pyramids' - and I take no credit for this package.
I have contributed this file solely for the convenience of other users.
### Package Contents: ###
* remove_unused_images.php
* readme.txt
Just made the file more Oscommerce compatible. The file is now loading within the original admin layout.
Nothing changed to the code itself. All credits by the original creator.
It appears I left out a line of code to read the checkboxes. This should fix it.
full mod
Scenario: I have 9000 image files. 2400 of them are not being used.
How to find them and remove them quickly and safely
What this script does:
* Read the database and report back a list of installed images
* Mark (in RED) any DB listed image which does not exist on the server
* Read the server images and report back a list
* Compare the lists for missing data
* Offer you the ability to check or uncheck listed images controlling what gets renamed
* Rename the USER checked listed images from myimage.jpg to UNUSED_myimage.jpg
* Allow you to ftp and delete ALL renamed UNUSED_myimage.jpg images