I've checked through the other posts, and I think I understand how to do a variable find and replace, but I'm missing the obvious it seems...
I have a few html files that have code like this in it...
<IMG src="thumbnails/th_My%20Photo.jpg"
I need to replace it with:
<IMG src="../vwimages/th_My%20Photo.jpg/$FILE/th_My%20Photo.jpg"
So should I be doing a simple find and replace or a batch?
I think this is how it should be done...
search:
<IMG src="thumbnails/th_(.*).jpg"
replace:
<IMG src="../vwimages/$1/$FILE/$1.jpg"
Does this make sense at all?
Wildcard F/R
In this version of Advanced Find and Replace you can use regular
expressions on Batch Replace tab.
The right regular expressions pair is:
Search for:
<IMG src="thumbnails/(th_.*)\.jpg"
Replace with:
<IMG src="../vwimages/$1/$FILE/$1.jpg"
. - dot before jpg is reserved char in search for (but not in replace
with!). So you have to escape it with \
Then in your example you have to put ( before th_
I verified it worked as expected.
expressions on Batch Replace tab.
The right regular expressions pair is:
Search for:
<IMG src="thumbnails/(th_.*)\.jpg"
Replace with:
<IMG src="../vwimages/$1/$FILE/$1.jpg"
. - dot before jpg is reserved char in search for (but not in replace
with!). So you have to escape it with \
Then in your example you have to put ( before th_
I verified it worked as expected.
Now what happens in the scenario where there is no "$FILE" in the search part, but is being added in the replace?
e.g. if I am searching for:
vwimages/(.*)\.jpg
and replacing with:
vwimages/th_$1.jpg/$FILE/$1.jpg"
The original string does not contain "$FILE" but is being inserted...
Even after some further testing, I guessing that "$FILE" is another reserved word... I think this copies the whole file and pastes it back in.. which might explain why my tables are being super-sized!
e.g. if I am searching for:
vwimages/(.*)\.jpg
and replacing with:
vwimages/th_$1.jpg/$FILE/$1.jpg"
The original string does not contain "$FILE" but is being inserted...
Even after some further testing, I guessing that "$FILE" is another reserved word... I think this copies the whole file and pastes it back in.. which might explain why my tables are being super-sized!