Question

firstly I'll give some background regarding the situation. I have a website containing approximately 56k pages each page contain a mapped sketch of a machine part. this machine part is made out of smaller parts which are outlined in the image and hold a certain number. when you hover over the numbers a box with the part item code shows up.

I order parts according to this item codes but recently a lot of the items codes have changed, therefore I am looking for a solution.

now I own a database with data on all the 56k parts and I want to link the relevant webpage to each record according to the name of the part(a column in my database), the problem is that the webpages names has no logic name that could connect with the part name in any way but the image that is displayed in the page has the exact name of the part.

I want to rename all the html files I has according to the Images displayed within them. how can I achieve that without renaming all the 56k pages manually?

additionally how can I add the links to all the 56k pages automatically to my database after all the above is done?

Thank you for your patience I know it was long.

Was it helpful?

Solution

If you have a *nix shell, then a simple egrep will get you far

egrep "<img src=\".*\"" -r . > list

The regexp would have to be adapted to match the part you are looking for of course.

You could easily to some search/replace in the resulting list to create a batch script that will do all the renaming for you.

OTHER TIPS

Pick your favorite scripting language and parse each html file to find the image name to use in renaming the file. Personally I would use Perl as it makes parsing the files and updating a database at the same time with the URL easy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top