bashrc – Create an alias that takes a file name as a paremeter, removes the extension of the parameter and creates a new extension

I want to create an alias in my ~/.bashrc file that takes a file as a parameter, removes the extension of that file, and adds a new extension.

For instance, instead of doing cp file.txt file.bak, I would do backup file.txt with the same result (obviously this is a silly example, not what I really want to do).

So I added this line in my ~/.bashrc file:

alias backup='cp $1 ${1%???}bak'

which should work, but it doesn’t. Any idea of what I’m doing wrong? Thanks.