Rename to specific filename via button

Hi i want to do a script that renames a file to a specific file name but it does not seem to work.

This is the code for the button:
Rename {filepath} TO folder.jpg

It just says "Cannot create a file when that file already exists."

Try something like this instead.

Rename TO "folder.jpg" AUTORENAME

The AUTORENAME argument will automatically rename the selected file to something like "folder (1).jpg" if you already have a folder.jpg file in the directory you're in.

Works great thanks alot.

You do of course realize that the error you're getting means that you already have a file in that folder called "folder.jpg"... and that John's suggestion will result in the file you're renaming being named "folder (1).jpg"... yeah? Is that really what you intend to happen...?