Here's a simple script for a procedure where you pass a database (and optional schema...else assume DBO) and you get a list of ALTER INDEX...REORGANIZE statements that target any indices fragmented more than 10% which you can change to suit your needs. The ALTER INDEX syntax for 2005/2008 replaces the DBCC INDEXDEFRAG which will soon be deprecated.
Be aware that this script takes quite a while to generate on a database with lots of indices, even with LIMITED being passed to dm_db_index_physical_stats for the sample quality.
If you feel comfortable with this script, you can obviously adapt it to execute each one of those ALTER INDEX statements automatically by reading from the table.
Enjoy!
Gaby Abed