Button to toggle file extension?

Hi. Very new user here, would like to make a toolbar button that would take a selection of files and toggle their extension between "txt" and "bak." That is, if the selected files are "txt" files they would become "bak" files and vice versa (all others would be ignored). Is it possible to do this?

This could be done a bit more efficiently using a rename script, but the way below is the simple method which should be fine unless you're renaming a huge number of files:

Rename PATTERN *.txt TO *.temp_bak Rename PATTERN *.bak TO *.txt Rename PATTERN *.temp_bak TO *.bak