Jump to content
Ketarin forum

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


vertigo
 Share

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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • 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.