Take a bottle and put a small piece of fruit or a bit of something like balsamic vinegar or wine in the bottom. Then take a piece of paper and roll it into a cone shape and put it in the mouth of the bottle. The flies will go in the bottle to get to the fruit or liquid, but they won't be able to get back out. It might take a couple days to get them all.
I used an almost empty bottle of apple cider vinegar. After a couple days, it was full of flies.