How change File Extension (from .zip to .cbz) in a script with "rename PATTERN"

I have a script

@set zip_file={file|noext}.zip
@set cbz_file={file}
@output: {$zip_file}
@output: {$cbz_file}
Rename PATTERN "{$zip_file}" TO "{$cbz_file}" NOIGNOREEXT

when I run it I get this log

test - Copy.zip
test - Copy.cbz
Rename PATTERN "test - Copy.zip" TO "test - Copy.cbz" NOIGNOREEXT

but the file doesn't change
image

But I don't see any error
Can someone help me to check what do I do wrong?

I do not have the same output as you do ... because it's not possible with your script !
My output :

test - Copy.zip
test - Copy.zip

You set zip_file to the name of the selected file, removing its extension and adding back ".zip"
You then set cbz_file to the name of the selected file ... which is the .zip !!!
After outputing the values, you rename the .zip to .zip ... nothing changes.

I suggest :

@set zip_file={file}
@set cbz_file={file|noext}.cbz
@output: {$zip_file}
@output: {$cbz_file}
Rename PATTERN "{$zip_file}" TO "{$cbz_file}" NOIGNOREEXT

EDIT : shorter version Rename PATTERN "{file}" TO "{file|noext}.cbz" NOIGNOREEXT

Why not simply Rename PATTERN *.zip TO *.cbz ?

(Also, although you don't need it here, you can use {file|ext=cbz} to get the name with its extension changed. Slightly nicer than {file|noext}.cbz )

NOIGNOREXT isn't needed here, FWIW (although it's harmless to include it):

You only need to use this argument when opening the Rename dialog for interactive use.

Thanks @PassThePeas and @Leo interresting observations.

I can't use this because I want to apply to only the specified file.
Then I decide to use your next suggestion

rename PATTERN "{file|ext=zip}" TO "{file|ext=cbz}"

but the problem persist. No change in the name "test - Copy.zip"
the log show perfectly

Rename PATTERN "test - Copy.zip" TO "test - Copy.cbz"

but my lister continue to show no name change
image

For testing I create a basic button with

@nofilenamequoting
@sync:
rename PATTERN "{file|ext=zip}" TO "{file|ext=cbz}"

This button works fine.
Then my issue has to be related with what happen in my other script. Then I will open a new entry with all the details to go more in depth.

Did you try it?

The command would only work on the selected file(s), which is the same thing your command using {file} is going to do.

If the two aren't equivalent, there may be a detail missing, like other things which are being done to the selected file(s) before the rename.

Correct Rename PATTERN *.zip TO *.cb. works only on selected file.
My error to assume, as there is a *, it will apply to all files as in MS/DOS for example.
But the error persist when integraded in my script.
This is why I open a post for looking at the complete script and find where something is affecting this rename PATTERN
I would close analisys here and would continue in

With the Rename command, that would happen with FROM *, which changes which files the command acts on (and also defines the "old name" pattern, if no other arguments override it).

But not PATTERN *, which just defines the "old name" pattern used to rename whichever files the command is acting on. Unless instructed otherwise, it'll work on the selected files.

2 Likes