Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Personalization
Expertise: Beginner
Apr 30, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

IMG tag and relative/evaluated location

We have a structure already defined that is now being modified, containing more than 400 pages that include IMG tags. The entire "mess" is being moved to another server/structure such that the relative references in the IMG tags will no longer be valid.

Is there any way other than (a) editing 400+ individual HTML docs, or (b) writing a script to perform the changes, that allows for the "../../" relative references in the IMG tags to be evaluated with some type of variable a la UNIX scripts? Or is this beyond the scope of basic HTML?

For example, IMG SRC="../../abc/mygif.gif" — is there any way to have "../../abc/" replaced with a variable entity/expression that can be evaluated in its place, as in: IMG SRC=some_token "mygif.gif"?

You will need to either run a script or use a local editor, such as HomeSite, to edit the path names. A simple search and replace script would be something like this:

#! /bin/csh

# Call this file snr.sh
# Replace FILE with * for all files, or a partial file name
# Replace OLDPATH with the old path name and NEWPATH with
# the new path name.
# Don't forget to backslash any slashes, so if the OLDPATH is
# ../../ you will need to type ..\/..\/

foreach f (FILE)
foreach g ($f/*.html)

	cat $g | sed -e 's/OLDPATH/NEWPATH/g' > tmp
	mv -f tmp $g
Place it in the root directory, and make it executable by typing:
%  chmod +x snr.sh
and run it by typing:
%  snr.sh
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date