I believe that under a proper *nix shell, this is just a single command line -- no script required, just a bit of xargs ..

Cheers