Rename the file

Hi

I have files like
aaaa_bbbb_tender_cccc.txt
aaaa_bbbb_britley_dddd.txt
aaaa_bbbb_wonder_eeee.txt

Now when my process runs, it will pick on of the above files and if process fails, file needs to be renames.
If file "aaaa_bbbb_tender_cccc.txt" fails, then file will be renamed to "aaaa_bbbb_tender_cccc.txt.bad". Any failed file will take a .bad at the end.

Problem is, i do not know what file will be picked and failed. I need use regular expression in both arguments on "mv" command. I can pass tender, britley and wonder as parameters. But how can i handle the second argument of mv

mv aaaa_bbbb_param_* aaaa_bbbb_param_"what should i fill here"

Please help me out

Provided your program "prog" gives off an exit code other than 0 if it fails you could try something like this:

for f in aaa_bbb_*.txt
do 
  prog "$f" || mv "$f" "$f.bad"
done