While it may be possible to do what you want with Fortran, it is not necessarily the best tool for the job. What you describe seem to be more of a job for a shell kind of environment (bash, batch) or, yes, one of those versatile scripting languages like Perl, or even better...Python ;-)
New...