How to select which command parameter TC should process?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
usertc
Junior Member
Junior Member
Posts: 2
Joined: 2016-07-17, 10:27 UTC

How to select which command parameter TC should process?

Post by *usertc »

Hello.
I have a command:

Code: Select all

magick.exe convert test_image.png -set filename:myname %date%_%time::=% %[filename:myname].bmp
It uses ImageMagick software and converts test_image.png to something like this: 17.07.2016_134435,30.bmp

It runs perfectly from the command line, but when I tried to create a button in Total Commander and replace test_image.png with %S, the command doesn't work. As I understand, Total Commander tries to process %d and %t which I don't want to be processed by it.

Is there any way to allow TC to process only %S command?

Also, if it's important, %date%_%time::=% expression is not for ImageMagick, it's for cmd.exe
So desired command would be like this:

Code: Select all

cmd magick.exe convert %S -set filename:myname %date%_%time::=% %[filename:myname].bmp
Where out of all parameters, TC should process only %S
User avatar
Dalai
Power Member
Power Member
Posts: 9409
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

Well, of course, this command can't work on a TC button because %date% and %time% are CMD env variables. So you need to create a button that launches cmd.exe and pass the necessary parameters to it. Furthermore, keep in mind that you have to double all percent signs in parameters that are not TC parameters/placeholders. Example: %date% would make TC use %d as replacement parameter like %S or %P, so you must use %%date%% to "mask" the percent signs and pass them unchanged to CMD.

I would create a batch script that takes the file names as parameters (or even better a file name of a list file containing all the file names to process by using %L) and create a button that passes them to this script. It's easier to understand later than having a button with all the cryptic stuff in it - not sure if the latter is possible at all.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
usertc
Junior Member
Junior Member
Posts: 2
Joined: 2016-07-17, 10:27 UTC

Post by *usertc »

Dalai, thank you so much! Masking helped. Also /c key was needed. So here is working button:

Code: Select all

Command: cmd /c magick.exe
Parameters: convert %S -set filename:myname %%date%%_%%time::=%% %%[filename:myname].bmp
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Finally, it is a good habit to additionally quote entire command line passed to stupid cmd.exe because it eats outer quotes if finds them (so it may cause unwanted eating):

Code: Select all

Command: cmd /c
Parameters: "magick.exe convert %S -set filename:myname %%date%%_%%time::=%% %%[filename:myname].bmp"
Post Reply