I’d do it from rails and skip the rake task. Administrative Bulk Operations might offer some hints on how to do that.