Remove List Item by Content

I am creating a list, but consistently have one item I’d like to exclude by content. I’ve read many threads here, but none cover how to address a list item by its content. I’ve tried something like:

delete every item of thelist that contains "The Bad Thing"

but no dice.

How do I identify a list item by content rather than by index?


you can do this only with a repeat loop.


but in the repeat loop, something like:

set set thedisklist to list disks
set thedisklistoutput to thedisklist as list

repeat with i from 1 to (count of thedisklistoutput)
if item i of thedisklist output is “Network”

–then do what? I’m stuck here, I don’t know how to specify and then remove that item…

end if
end repeat

That command returns a list. You are putting that list inside another list and then looping over that second list.


tell application "System Events" to set diskList to name of disks whose name is not "Network"

Thanks very much Bruce, this was just what I needed.