Cool.
Here is the finished script. All you have to do is select all or part of the product you want to deactivate in lines 31 thru 125 in the xml file at the bottom of this post. and run the script. The script will then find the chronological product number by subtracting the line number of the product from the line number of the tag and then count over to the correct color tag entries and the specialClasses tags and delete them.
I think I commented them pretty well. I hope this helps someone out as you’ve helped me out.
I didn’t get rid of the “of window 1” part because they were already there but the AS project I have will include what you’ve taught me.
--Select the product to be deleted first
tell application "BBEdit"
set myProduct to the selection of text window 1
set tagLength to 41 + 1
set colorCodeLength to 8
set specialClassesLength to 2
set thumbsLine to "<thumbs>"
set headlineColors to "headlineColors"
set subheadlineColors to "subheadlineColors"
set legalColors to "legalColors"
set specialClasses to "specialClasses"
-------------------------------------------------
--find the line that the thumbs tag is on
find thumbsLine searching in text 1 of text window 1 options {search mode:text, starting at top:true, backwards:false, case sensitive:false, match words:false, extend selection:false} with selecting match
copy the startLine of selection of window 1 to thumbsLineCount
-------------------------------------------------
--find the line that the desired product tag is on
find myProduct searching in text 1 of text window 1 options {search mode:text, starting at top:true, backwards:false, case sensitive:false, match words:false, extend selection:false} with selecting match
copy the startLine of selection of window 1 to productLineCount
-- and subtract it from the thumbs line
set productNumber to productLineCount - thumbsLineCount
set productColor to productNumber - 1
-----------------------------------------------
--LINE COUNT 1
--find the text color tag and get its line number and set var lineCount1
find headlineColors searching in text 1 of text window 1 options {search mode:text, starting at top:true, backwards:false, case sensitive:false, match words:false, extend selection:false} with selecting match
copy the startLine of selection of window 1 to lineCount1
--select first char of chosen product color
select character (productColor * colorCodeLength + tagLength) of line lineCount1 of text of window 1
set startMark to characterOffset of selection of text window 1
-- and find next pipe char and extend selection
set targetColor to find "[|]" searching in text 1 of text window 1 options {search mode:grep, starting at top:false, wrap around:false, backwards:false, case sensitive:true} with extend selection
set endMark to characterOffset of targetColor's found object
select (characters startMark thru endMark) of text window 1
set text of selection to ""
-----------------------------------------------
--LINE COUNT 2
--find the text color tag and get its line number and set var lineCount2
find subheadlineColors searching in text 1 of text window 1 options {search mode:text, starting at top:true, backwards:false, case sensitive:false, match words:false, extend selection:false} with selecting match
copy the startLine of selection of window 1 to lineCount2
--select first char of chosen product color
select character (productColor * colorCodeLength + tagLength) of line lineCount2 of text of window 1
set startMark to characterOffset of selection of text window 1
-- and find next pipe char and extend selection
set targetColor to find "[|]" searching in text 1 of text window 1 options {search mode:grep, starting at top:false, wrap around:false, backwards:false, case sensitive:true} with extend selection
set endMark to characterOffset of targetColor's found object
select (characters startMark thru endMark) of text window 1
set text of selection to ""
-----------------------------------------------
--LINE COUNT 3
--find the text color tag and get its line number and set var lineCount3
find legalColors searching in text 1 of text window 1 options {search mode:text, starting at top:true, backwards:false, case sensitive:false, match words:false, extend selection:false} with selecting match
copy the startLine of selection of window 1 to lineCount3
--select first char of chosen product color
select character (productColor * colorCodeLength + tagLength) of line lineCount3 of text of window 1
set startMark to characterOffset of selection of text window 1
-- and find next pipe char and extend selection
set targetColor to find "[|]" searching in text 1 of text window 1 options {search mode:grep, starting at top:false, wrap around:false, backwards:false, case sensitive:true} with extend selection
set endMark to characterOffset of targetColor's found object
select (characters startMark thru endMark) of text window 1
set text of selection to ""
-----------------------------------------------
--LINE COUNT 4
--find the text color tag and get its line number and set var lineCount4
find specialClasses searching in text 1 of text window 1 options {search mode:text, starting at top:true, backwards:false, case sensitive:false, match words:false, extend selection:false} with selecting match
copy the startLine of selection of window 1 to lineCount4
--select first char of chosen product color
select character (productColor * specialClassesLength + tagLength) of line lineCount4 of text of window 1
set startMark to characterOffset of selection of text window 1
-- and find next pipe char and extend selection
set targetColor to find "[|]" searching in text 1 of text window 1 options {search mode:grep, starting at top:false, wrap around:false, backwards:false, case sensitive:true} with extend selection
set endMark to characterOffset of targetColor's found object
select (characters startMark thru endMark) of text window 1
set text of selection to ""
end tell
--replace (characters 114 thru 121 of line 14) of text window 1 using ""
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<?xml version="1.0" encoding="utf-8"?>
Lifestyle_AFrame
Description
Notes
0.125in
0.5in
#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#663700|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#663700|#663700|#FFFFFF|#FFFFFF|#663700|#663700|#663700|#663700|#663700|#663700|#FFFFFF|#663700|#663700|#663700|#FFFFFF|#FFFFFF|#663700|#663700|#FFFFFF|#FFFFFF|#663700|#FFFFFF|#FFFFFF|#663700|#FFFFFF|#663700|#FFFFFF|#663700|#FFFFFF|#FFFFFF|#663700|#663700|#663700|#FFFFFF|#663700|#663700|#FFFFFF|#663700|#FFFFFF|#FFFFFF|#663700|#663700|#FFFFFF|#663700|#663700|#FFFFFF|#663700|#663700|#FFFFFF|#663700|#663700|#FFFFFF|#663700|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#663700|#663700|#FFFFFF|#663700|#FFFFFF|#FFFFFF|#FFFFFF|#663700|#663700|#663700|#663700|#663700
#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#663700|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#663700|#663700|#FFFFFF|#FFFFFF|#663700|#663700|#663700|#663700|#663700|#663700|#FFFFFF|#663700|#663700|#663700|#FFFFFF|#FFFFFF|#663700|#663700|#FFFFFF|#FFFFFF|#663700|#FFFFFF|#FFFFFF|#663700|#FFFFFF|#663700|#FFFFFF|#663700|#FFFFFF|#FFFFFF|#663700|#663700|#663700|#FFFFFF|#663700|#663700|#FFFFFF|#663700|#FFFFFF|#FFFFFF|#663700|#663700|#FFFFFF|#663700|#663700|#FFFFFF|#663700|#663700|#FFFFFF|#663700|#663700|#FFFFFF|#663700|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#663700|#663700|#FFFFFF|#663700|#FFFFFF|#FFFFFF|#FFFFFF|#663700|#663700|#663700|#663700|#663700
#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#000000|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#000000|#000000|#FFFFFF|#FFFFFF|#000000|#000000|#000000|#000000|#000000|#000000|#FFFFFF|#000000|#000000|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#000000|#FFFFFF|#FFFFFF|#000000|#FFFFFF|#000000|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#000000|#000000|#000000|#FFFFFF|#FFFFFF|#000000|#FFFFFF|#000000|#FFFFFF|#FFFFFF|#000000|#000000|#FFFFFF|#000000|#000000|#FFFFFF|#000000|#FFFFFF|#FFFFFF|#FFFFFF|#000000|#FFFFFF|#000000|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#FFFFFF|#000000|#000000|#FFFFFF|#000000|#FFFFFF|#FFFFFF|#FFFFFF|#000000|#000000|#663700|#000000|#000000
-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|gradient|-|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|gradient|-|-|-|-|-|-
For FREE offers, the font size of the product name must be at least half the font size of the word FREE. Use the return key to move text to the next line. To insert a ¢, type "ALT+0162" (Windows) or "Option+4" (Mac)
130|100|70
54|44|34
Iced Green Tea, Orig. Iced Tea and Iced Sweet Tea
Raspberry and Oreo Cheesecake Square
Southwest Supreme Bagel
Spicy Omelet Breakfast Sandwich and Wake-up Wrap
K-cup and Pound of Coffee
Snack N Go Chicken Wrap
Coffee and Espresso Line
Turkey Sausage Flatbread and Wake Up Wrap
BR Coffee Flavors
Cookie Dough Heart Shaped Donuts
Dark Roast K Cup and Pound Of Coffee
Dark Roast and Hot Cocoa K Cups
White Chocolate Raspberry Lattes with Heart Shaped Donut
Tomato Mozzarella Supreme Bagel
Angus Steak and Egg Breakfast Sandwich
Croissant Donut
Dunkin Go Bar
Spinach Artichoke Supreme Bagel
Cold Beverage
Happy Hour
Hot Dark Roast
Hot and Iced Dark Roast
Frozen Coffee Coolatta Swirl
Chicken Bacon Croissant Sandwich With Hashbrowns And Iced Tea
Grilled Chicken Flatbread With Bakery Line
Pretzel Twist with Beverage
Iced Coffee Suite
Box O' Joe and Dozen Donuts
Iced And Hot Coffee Suite
Glazed Donut Breakfast Sandwich
Iced Green Tea
Grilled Chicken Flatbread Sandwich & Iced Tea
3 Hopper Hot Chocolate Suite
5 Hopper Hot Chocolate Suite
Bacon Ranch Chicken Sandwich with Iced Tea
Espresso Line
Hot & Iced Lattes
Hot Latte
Deluxe Grilled Cheese Sandwich Line & Iced Tea
Roast Beef Pretzel Roll Sandwich & Coca-Cola®
Iced Tea & Iced Coffee
Chicken Salad & Tuna on a Bagel Sandwiches
Iced Tea
Roast Beef Pretzel Roll Sandwich & Iced Tea
Bakery Sandwich Line
COOLATTA® Line
Hot Coffee, Iced Coffee & Hot Latte
Southern Style Biscuit Line
Sweet Tea
Tuna & Chicken Salad Wraps
Peppered Fried Egg & Sausage on Croissant
Turkey Sausage Sandwich, Wake-Up® Wrap & Iced Coffee
Egg & Cheese Wake-Up® Wrap
Four Breakfast Sandwiches
Big N' Toasted® & Hot Coffee
Big N' Toasted® & Iced Coffee
Hot Coffee Pour
Chicken Biscuit & Hot Coffee
Dozen Donuts
Turkey, Bacon & Cheddar and Ham & Cheese
Big N' Toasted® & Hash Browns
Bagel Twists & Hot Coffee
Donut & Hot Coffee
Coffee Roll
MUNCHKINS® & Hot Coffee
Half Dozen Donuts
Iced Latte Line
Frozen Beverage Line
Muffin Varieties
K-Cup® & Brewer
Bagels
Mocha Latte & Hot Coffee
Oatmeal
Bulk Items
Chicken Biscuit & Sweet Tea
Bagel Twists & Iced Tea
Bagel Twists & Iced Coffee
Chicken Salad Sandwich & Iced Tea
Tuna on Bagel & Iced Tea
Tuna Melt & Iced Coffee
Bagel with Cream Cheese & Hot Coffee
Pound of Coffee Line
Pound of Coffee
2 Pounds of Coffee
Bagel & Iced Coffee
Brownie & Hot, Iced Coffee
Mocha Swirl Iced Coffee & Latte
Cookies
Hash Browns in Bag
Turkey Sausage Breakfast Sandwich
Hot Chocolate & DUNKACCINO®
Iced Coffee & Two Donuts
Iced Coffee & Single Donut
Sliced Turkey Breakfast Sandwich
Better for You Breakfast Sandwiches
lifestyleSuite