Rename *.zip to *.cbz

I am trying to set up a button to do this for the selected files but cannot get it to work :frowning:

I cloned the _ removal command which works well but this one does not

rename PATTERN=".zip" TO=".cbz" FINDREP=ext

What magical incantation is required for this to work?

thanks...

Hi,

you should try this :slight_smile:

Rename FROM ".zip" TO ".cbz"

Use this:

@nofilenamequoting Rename PATTERN=".zip" TO=".cbz" FINDREP=ext
You do not need the asterisks, because the command will actually find all occurrences the value of PATTERN and replace it with the value of TO.

The Command Parser sometimes gets automatic quotes incorrect. I always recommend @nofilenamequoting, which suppresses the Command Parser's automatic quotes. Then I add my own quotes where I know they belong in the command. They way your command was, Opus might have tried to put in two sets of quotes around names with spaces.

It could be a smart thing to keep the asterisks, because if one of the names contains the ".zip" string within, like "my.zip.files.txt" it'll be changed to "my.cbz.files.txt".

Is that right ?

[quote="megosu"]It could be a smart thing to keep the asterisks, because if one of the names contains the ".zip" string within, like "my.zip.files.txt" it'll be changed to "my.cbz.files.txt".

Is that right ?[/quote]

Not with this syntax : FINDREP=ext means you use the Find and Replace method which doesn't allow "*" Using an asterisk there would not work at all.

To do what you want, i would use a regexp like :

@nofilenamequoting Rename PATTERN="^(.*)\.zip$" TO="\1.cbz" REGEXP

Or your solution too, megosu, yes, no need to use regular expressions :slight_smile:

Thanks :smiley:

I could not use FROM because I want to change only the selected files.

Even with the @nofilenamequoting it still does not like the *

I tried both methods and they both work.

Frv has posted the best solution. That should ensure you only change the file extension. When in doubt, RegExp is usually the most exact way to do something like this, though it may take some time to come up with an air-tight RegExp.

Just my 2 cents:

Blanket recommendations of @nofilenamequoting only complicate things, IMO. With a simple X="Y" command, as in all of these examples, there's never any need to use it.

You generally only need @nofilenamequoting when joining tokens together, like X="C:{file}" or similar. (I'm not sure whether Opus auto-quotes that correctly or not, so even then it may not be needed.)

It is true that you can always use @nofilenamequoting and put the quotes in yourself and it will never cause a problem, but I think it can complicate discussion and lead to red herrings and it makes buttons harder to understand for new users since there's this extra thing being used that they might not know the meaning of.

Again, just my 2 cents and it's not a big deal.

PS: An even simpler solution is this:

Rename PATTERN="*.zip" TO="*.cbz"

megosu almost had it in the first reply, but used FROM instead of PATTERN. FROM is used to specify which files will be renamed (so that the command ignores the file selection, or can run without a lister at all, e.g. as a standalone hotkey) while PATTERN is used to specify the "old name" pattern for the rename.

True this one is the simplest :

Rename PATTERN="*.zip" TO="*.cbz"

I found it afterwards when takarada just ask for only the selected files to be modified, but I didn't dare to post it, there were already 2 good solutions ^^