Jump to content
Ketarin forum

Confusing command design regarding "batch file" variables and inability to use {}'s in commands

Recommended Posts

Not a bug but rather an issue with the design. The commands tab uses the term "Batch script" which would indicate the need to use double percents (%%) in a for loop, but after spending probably close to 15 minutes trying to figure out why a simple script wasn't working no matter what I tried, I finally changed them to single percents (%) and it worked. So clearly Ketarin is running the commands directly, not as a batch file as implied, causing much confusion and wasted time. This should be clarified somehow.

Also, the special variables page states simply (and confusingly), that the {file} variable should be enclosed "in double quotes (”) if the path contains spaces." There are two issues here: it doesn't specify whether the quotes need to be inside (which I wrongly assumed) or outside (what I found after much troubleshooting) the braces and the term "double quotes" implies it needs to be ""{...}"" which is clearly not the case, and it should simply say "quotes."

Finally, I tried including {}'s as part of a command (7z.exe e -o{%download_path%} "{file}" *.exe) but it wouldn't work, presumably due to Ketarin thinking the {%download_path%} was one of its variables, even though such a variable doesn't exist. So unless I'm missing something, it seems impossible to have 7-Zip unpack a download into the download directory without first changing to that directory, which is also much harder than it should be due to a lack of a {download_path} variable (an issue I've submitted on userecho).

Link to post
Share on other sites

You're confusing two languages: batch and Ketarin. Ketarin variables are the native variables as well as those you create yourself on the variables page. The Ketarin variables are, of course, processed before batch variables since the batch script is generated *from* Ketarin. This means that you will never use a "{%whatever%}" syntax, but might very well use a "%{whatever}%" syntax, depending on what you're putting in your variables. You could, for example, use a global Ketarin variable to specify what path you would like to extract to and use that in place of the {whatever} and have it processed by the batch script.

"{file}" is the proper way to wrap the filename if it has spaces or other special characters (like ampersands).

There are MANY EXAMPLES on this forum of using 7-zip to extract files to specific directories.

As for the directory thing - you'll want to look at the functions page on the wiki for stuff like {file:directory}:

7z.exe e -o"{file:directory}" "{file}" *.exe


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.