I've been using one of Leo's rename scripts in the advanced rename dialogue. It works fine on a selection of files using "*" as the old name and "S0E[NUM]" as the new name (the script is coded to replace the [NUM] with the next unused number) but I'd like to execute it from a button so I don't have to open the dialogue each time.
I know that buttons can execute scripts, but I can't find anything that says how, or if, a button can execute a .orp rename script: all of the rename buttons I've found on this forum seem to hold the script within the button itself. I'd rather call the existing script than duplicate it into a button (and anyway, I haven't been able to get it to work from the button yet).
Is it possible to execute a .orp script on a given selection of files? If not, then I'll just use a button and delete the .orp script so I only have one copy.
(The stuff below here can be ignored if there's a way to run the .orp)
I've got the script working in a button. I'd copied the script from the advanced rename dialogue, rather than opening the .orp file itself and copying from there. Based on what I saw in other scripts, I tried adding this line to the top, taking the working values from the dialogue's old and new name field:
RENAME FROM="*" TO="S0E[NUM]"
but that just acted on all of the files instead of the selection and stripped the file extension from the names. I've since read the description of the FROM argument and comments in the forum making it clear that this makes the Rename command ignore the files passed to it. Based on those comments, I tried this:
RENAME PATTERN="*" TO="S0E[NUM]"
This works on the selected files but still strips the extensions. The script doesn't appear to work with extensions, leaving that to the rename dialogue (I have "Ignore extension" ticked). Putting the extensions into the patterns works, e.g.:
RENAME PATTERN="*.mp4" TO="S0E[NUM].mp4"
However, the files may not always be of the same format, so I'd rather not hardcode them like that, nor do I currently know enough to amend the script to preserve them. This seems to work:
RENAME PATTERN="(.+).(.[^.]+)" TO="S0E[NUM]\2" REGEXP
Is there a better/simpler way of doing it?
Thanks in advance.