You might try simplifying your code. Just get the quote portion of the file then add your header and footer around it.
<!--- original file --->
<cffile action="read" file="#filestoragelocation#/#cffile.serverFile#" variable="originalFile">
<cffile action="read" file="#templatelocation#/remove1.html" variable="oldHeader">
<cffile action="read" file="#templatelocation#/remove2.html" variable="oldFooter">
<cffile action="read" file="#templatelocation#/add1-1.html" variable="newHeader">
<cffile action="read" file="#templatelocation#/add2w.html" variable="newFooter">
<cfset quotePart=Replace(originalFile, oldHeader, "")>
<cfset quotePart=Replace(quotePart, oldFooter, "")>
<cfset newQuote=newHeader & quotePart & newFooter>
<cffile action="write" file="#filestoragelocation#/M#cffile.serverFile#" output="#newQuote#">
It might be useful to have a basic example of the files you are working with.
Hey there Bob -
Thanks for the response...unfortunately...the Old Header and Old Footers can change dynamically because they're from a 3rd party website...so what i've tried to do is grab pieces of the formatting...because that rarely changes...that terminates the header and starts the footer...and then use left and right to capture the rest of the header and footer. Does that make sense? And the rest of the header and footer has information that may or may not stay consistent. So unfortunately, its not as black and white as just selecting all of the header and footer and replacing them.
Thanks for giving it a shot though! My code is really close...its just something about the logic is slightly off with the footer.
Perhaps you could post some basic examples of the files you are working with so that we can re-create the problem you are having?
You say the first part is working so I will take your word for that, although it doesn't look right.
The second part need probably isn't working because youre calculating the Right X chars but you are counting the chars by finding the index of your find from the beginning. So imagine you are replacing the first 10 chars with your new header. Your doc is 100 chars total. You wnat to replace the last 10 characters. Your find returns 90 because you started from the beginning. You grab the Right 90 chars, taking you to the end of the header, and you are replacing all that with the footer.
What you want is Replace(quoteedit, RIGHT(quoteedit,Len(quoteedit)-find(oldfooter,quoteedit)), newfooter). That should work.
Ahhh you're right! Didn't stop to think about where the count was counting from. Thanks so much for the help!