klownboy wrote:Thanks PeterH, I saved this post in my "Fun with XY Quoting" Favorites folder.

I do typically double quote in scripts even when it's an assigned variable as an example,
Code: Select all
$g_IrfanPath="d:\graphics\irfanView\i_view32.exe";
run """$g_IrfanPath"" $file /aspectratio /jpgq=100 /crop=($x_crop, $y_crop, $width, $height) /convert=$path\". $base ."_$xy.$ext", , 2,0;
but I had tested what I had posted earlier, it worked and never thought about spaces (obviously I don't have spaces in my XY command line). Now maybe the above isn't totally correct either but it has worked for me for last couple of years.
Thanks again,
Ken
I think your wording doesn't exactly fit the statements
In both lines you use text-strings, containing characters as
c: or
/aspectratio - and these
must be quoted. That is: quotes are needed!
Next you use the ability of XY, that
variables inside double quotes are resolved. So it generally isn't necessary to take the variables outside the quotes and use concatenation. So I'd say: the variables are
not explicitely quoted - they are just inside quotes.
And there is one (solved) problem: a variable inside double quotes must be recognized. That's easy if it's name is
followed by a blank or another character that is not allowed in variable names. But the variable $base is followed by an underscore - if it would be inside the double quotes it would be trated as $base_

you correctly have pulled these apart by concatenation.
And the very last to say (I think) is to the doubled quotes in
run """$g_IrfanPath"" ... These are not for XY, but for the run command, to possibly recognize the file, though it's name might contain blanks. You could have changed that as
Code: Select all
$g_IrfanPath="""d:\graphics\irfanView\i_view32.exe""";
run "$g_IrfanPath $file /aspectratio /jpgq=100 /crop=($x_crop, $y_crop, $width, $height) /convert=$path\". $base ."_$xy.$ext", , 2,0;
the result would exactly be the same. This shows: the doubled double quote leads to a double quote in the resultant string. And as the 1st statement
contains no variable:
Code: Select all
$g_IrfanPath='"d:\graphics\irfanView\i_view32.exe"';
run "$g_IrfanPath $file /aspectratio /jpgq=100 /crop=($x_crop, $y_crop, $width, $height) /convert=$path\". $base ."_$xy.$ext", , 2,0;
the same again, i.e. double quotes inside single quotes are not doubled
