variables as parameters in CLI

Discuss RoboTask here
Post Reply
photoevents
Posts: 49
Joined: Mon Jan 01, 2024 11:21 am
Contact:

variables as parameters in CLI

Post by photoevents »

When using variables as parameters when starting a program I needed to use a double \\ before the variable name if it was in a string in my previous software.
Like this: %WORKFOLDER%\qrcodes\\%FileName%.png
How do you do that in robotask?
(I'm having trouble finding examples of this)

Another example that works in my previous script:

convert.exe "%CurrentItem%" -quality "70" -resize "990x1490^" -gravity "North" -extent "1200x1800" "%WORKFOLDER%\overlay\\watermark.png" -compose over -composite "%WORKFOLDER%\merged\\%FileName%"

how does that translate to robotask?

Christian
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: variables as parameters in CLI

Post by Oleg »

...how does that translate to robotask?...
I'm sorry I don't understand you...
Do you want to put double backslash (\\) before environment variable? Or remove extra slash?
...if it was in a string in my previous software...
What do you receive from "previous software" and what do you want to get as a result?

Or do you want to expand environment variables in string?
Oleg Yershov
photoevents
Posts: 49
Joined: Mon Jan 01, 2024 11:21 am
Contact:

Re: variables as parameters in CLI

Post by photoevents »

Apologies if my query was unclear.

When starting a program using robotask run console application it is possible to add parameters.
Do I have to take special measures when merging variables within the command line ?
Like in winautomation it would be:
%WORKFOLDER%\qrcodes\\%FileName%.png (one extra backslash to make sure the variable is recognized as a variable)
and I guess in robotask this would be:
{WORKFOLDER}\qrcodes{FileName}.png
Correct?

Do I need to take certain measures (quotes, special characters, backslash, {} ) so robotask does not misinterpret the command line?

Thanks,
Christian
Last edited by photoevents on Mon Jun 17, 2024 11:46 am, edited 1 time in total.
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: variables as parameters in CLI

Post by Oleg »

Do I have to take special measures when merging variables within the command line ?
No.
Like in winautomation it would be:
%WORKFOLDER%\qrcodes\\%FileName%.png ...
System (Windows™) uses expressions like %WORKFOLDER% and %FileName% for environment variables in CMD or BATH files. Do you use environment variables?
and I guess in robotask this would be:
{WORKFOLDER}\qrcodes{FileName}.png
I think you missed one backslash.
No problem, use the expression as it is:
{WORKFOLDER}\qrcodes\{FileName}.png
without problem. If WORKFOLDER and FileName are internal user variables of RoboTask then the action engine expands then and put values instead of expressions {WORKFOLDER} and {FileName}
Oleg Yershov
photoevents
Posts: 49
Joined: Mon Jan 01, 2024 11:21 am
Contact:

Re: variables as parameters in CLI

Post by photoevents »

https://titeca.biz/web_images/identifyex.JPG
Image

This does not generate a txt output.
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: variables as parameters in CLI

Post by Oleg »

use photoheight without braces
If you want to save something to variable you should specify variable name only. It's better to specify the name explicitly.
You can use other variables to form variable name, but I'm afraid that variable photoheight does not contain any value at this moment
Oleg Yershov
photoevents
Posts: 49
Joined: Mon Jan 01, 2024 11:21 am
Contact:

Re: variables as parameters in CLI

Post by photoevents »

Okay, got it working

The whole command line is:
identify -format "%h" "{current_image}"
to get the height of the image


more info on imagemagick identify for those interested:
https://imagemagick.org/Usage/basics/#identify
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: variables as parameters in CLI

Post by Oleg »

By the way, take a look at the Open Image action.
When you open an image from a file or clipboard, it can determine the height and width of the image.
Oleg Yershov
Post Reply