Check if paperfolder active

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Stef123

Re: Check if paperfolder active

Post by Stef123 »

SammaySarkar wrote:The problem is probably that the program wasn't found. Do you have <xypath>\..\XnUtilities\NConvert\nconvert.exe?
Yes, the path is correct. Irrespective of runret (@Ken, I use runret to NOT see the black DOX box) - this here works:

Code: Select all

run "cmd /c <xypath>\..\XnUtilities\NConvert\nconvert.exe -o ""U:\Outbox\$NameNew#.jpg"" -ratio -resize 1920 0 ""$item""";
Whereas this does NOT work:

Code: Select all

run """cmd /c <xypath>\..\XnUtilities\NConvert\nconvert.exe"" -o ""U:\Outbox\$NameNew#.jpg"" -ratio -resize 1920 0 ""$item""";
And yes, I've been using this and other calls from the command prompt and elsewhere - nowhere do I experience syntax problems.

The problem is NOT that I can't get things to work in XY - it always gets figured out thanks to you guys, sooner or later - and this is OK for private use and my learning curve. But tied up in a client's environment, I cannot afford to worry so much about the tool itself. I need an EASY way to do things. I hate those embarrassing moments that make me - the consultant - look incompetent, unable to even handle his own tools.

I've given up on renames because of RegEx - I pass it along to other managers. Same with archives, same with previews, same for the heavy lifting in networks, but since XY is my main launchbar, my switchboard, I'd love to be able to set up external calls ad hoc, whenever the need arises. On the first go-around, not the third, with as little aggravation as possible.

3 double quotes at the beginning when I need command line parameters - that's good, I like guidelines like that. And it works. Mostly. And then again it doesn't.

@Ken,
thanks for the alternative declaring a variable instead. From what I see you're not following the rule of 3-dbl-quotes up front. So in essence you're using the same syntax I had arrived at (by NOT following the guidelines here:
http://www.xyplorer.com/xyfc/viewtopic. ... 846#p40846
Anyway, the quoting and syntax confusion remains the same, it just gets shifted into the variable part.

totmad1
Posts: 131
Joined: 24 Jun 2013 12:37

Re: Check if paperfolder active

Post by totmad1 »

If you like nconvert i have written a script using heredoc

Code: Select all

"_Initialize" ; perm $nconvert="%Porta%\XnViewNConvert\nconvert.exe";
                perm $p_help = "%Porta%\XnViewNConvert\nchelp.txt";
"_Terminate" ; unset $nconvert; unset $p_help
"new selfilter (odd)" selfilter "1,2", , "#";
"new selfilter (even)" selfilter "2,2", , "#";
"Show only selected" #359;
"toggle filter " #355;
"HELP |<xyicons>\Help.ico | 1"
       if(exists("$p_help")==0){
      run("cmd /c $nconvert -help > $p_help");
      }
      wait 500;
     // open "$p_help";
      openwith ("$p_note" "$p_help");
"split Left_Right 50%|%Porta%\XnViewNConvert\nconvert.exe";
             $SelectedItems = get("SelectedItemsPathNames", "|");
   foreach($Item, $SelectedItems, "|") {
		$w1 = property("ImageX", $Item);  $h1 = property("ImageY", $Item);
		 $w12 = $w1 * 0.5; $wh = 0 0 $w12 . " " . $h1;
         $cmdline = <<<CMD_LINE
cmd /c $nconvert -crop $wh ""$Item""

CMD_LINE;
         $cmdline = Replace($cmdline, "<crlf>", ' ');
         Run($cmdline, , 0, 0);
         $cmdline1 = <<<CMD_LINE1
cmd /c $nconvert -crop $w12 0 $w12 $h1 ""$Item""

CMD_LINE1;
         $cmdline1 = Replace($cmdline1, "<crlf>", ' ');
         Run($cmdline1, , 0, 0);
	    }
"trim Left or Right w input|%Porta%\XnViewNConvert\nconvert.exe";
             $SelectedItems = get("SelectedItemsPathNames", "|");
            $num = input("Enter in %", "i.e. 23 (=23%trim right)  ( -23 =23%trim left)", "23");
               $num =($num /100);
   foreach($Item, $SelectedItems, "|") { 
	$w1 = property("ImageX", $Item); $h1 = property("ImageY", $Item);
	  if ($num <= 0) {
        $num1 = (1 + $num);
        $w12 = $w1 * $num1;
        $w11 = abs($w1 * $num);
        $dim = $w11 0 $w12 $h1;
	}
	else {
        $num1 = (1 - $num);
        $w12 = $w1 * $num1;
        $dim = 0 0 $w12 $h1;
             }
         $cmdline = <<<CMD_LINE
cmd /c $nconvert -crop $dim ""$Item""

CMD_LINE;
         $cmdline = Replace($cmdline, "<crlf>", ' ');
         Run($cmdline, , 0, 0);
            }  msg "All Done";
"split Top_Bottom 50%|%Porta%\XnViewNConvert\nconvert.exe";
             $SelectedItems = get("SelectedItemsPathNames", "|");
   foreach($Item, $SelectedItems, "|") {
		$w1 = property("ImageX", $Item);  $h1 = property("ImageY", $Item);
		 $h12 = $h1 * 0.5; $wh = 0 0 $w1 . " " . $h12;
         $cmdline = <<<CMD_LINE
cmd /c $nconvert -crop $wh ""$Item""

CMD_LINE;
         $cmdline = Replace($cmdline, "<crlf>", ' ');
         Run($cmdline, , 0, 0);
         $cmdline1 = <<<CMD_LINE1
cmd /c $nconvert -crop 0 $h12 $w1 $h12 ""$Item""

CMD_LINE1;
         $cmdline1 = Replace($cmdline1, "<crlf>", ' ');
         Run($cmdline1, , 0, 0);
	    }
"Aspect 16:9 padded|<xydata>\icons\xy-script.ico"
   $SelectedItems = get("SelectedItemsPathNames", "|");
   foreach($Item, $SelectedItems, "|") {
                    $w1 = property("ImageX", $Item);
		    $h1 = property("ImageY", $Item);
		    $w2 = floor($h1 * 1.778) ;
		    if($w1 > $w2){
		$h2 = floor($w1 / 1.778);
                 $wh2 = $w1 . " " . $h2;
        $cmdline = <<<CMD_LINE
cmd /c $nconvert -canvas $wh2 center -bgcolor 255 0 0 ""$Item""

CMD_LINE;
         $cmdline = Replace($cmdline, "<crlf>", ' ');
         Run($cmdline, , 0, 0);  }
         elseif ($w2 > $w1) {
		$wh2 = $w2 . " " . $h1;
        $cmdline = <<<CMD_LINE
cmd /c $nconvert -canvas $wh2 center -bgcolor 0 0 255 ""$Item""

CMD_LINE;
         $cmdline = Replace($cmdline, "<crlf>", ' ');
         Run($cmdline, , 0, 0);  }
		    } text All Done;
-
"Aspect 16:9 cropped|<xydata>\icons\xy-script.ico";
           $SelectedItems = get("SelectedItemsPathNames", "|");
   foreach($Item, $SelectedItems, "|") { 
                 $w1 = property("ImageX", $Item);
		 $h1 = property("ImageY", $Item);
				 $wh = $w1 . x . $h1;
					$w2 = floor($h1 * 1.778) ;
					if($w1 > $w2){
					$h2 = floor($w1 / 1.778); $wh2 = $w2 . " " . $h1;
        $cmdline = <<<CMD_LINE
cmd /c $nconvert -canvas $wh2 center ""$Item""

CMD_LINE;
         $cmdline = Replace($cmdline, "<crlf>", ' ');
         Run($cmdline, , 0, 0);
		    }
                    	elseif ($w2 > $w1) {
					$h2 = floor($w1 / 1.778);
					$wh2 = $w1 . " " . $h2 . ^ ;
        $cmdline = <<<CMD_LINE
cmd /c $nconvert -canvas $wh2 center ""$Item""

CMD_LINE;
         $cmdline = Replace($cmdline, "<crlf>", ' ');
         Run($cmdline, , 0, 0);
		    }   }
totmad1 (totally mad one)

highend
Posts: 14953
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Check if paperfolder active

Post by highend »

No PC to check anything here...

Did you try this?

Code: Select all

runret("""cmd"" /c ""<xypath>\..\XnUtilities\NConvert\nconvert.exe"" -o ""U:\Outbox\$NameNew#.jpg"" -ratio -resize 1920 0 ""$item""");
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4462
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Check if paperfolder active

Post by klownboy »

Stef123 wrote:Ken, I use runret to NOT see the black DOX box
I wasn't getting a black box box using cmd /c with run. I'm surprised you were. Typically runret is not used in cases like this. Help - "Runs a command line and returns the standard output"
Stef123 wrote:From what I see you're not following the rule of 3-dbl-quotes up front.
When you use a heredoc or run a variable as I did in the example, that 3-dbl quote rule you refer to doesn't apply. It's actually a little simpler in most cases to do that. See totmad1's script above.

Thank you totmad1 for the nconvert script. I'll give it a try in the morning. Aren't you the one (totally mad one) that used Image Magick in some of your XY scripts if I recall properly. Still using it or are you using them all?

Stef123

Re: Check if paperfolder active

Post by Stef123 »

Thank you guys,
didn't mean to turn this into a nconvert or runret challenge. Again, I don't have an acute problem, my calls have been working nicely, it's just that I am trying to come to grips with scripting in general, wondering if there are shortcuts, better (easier) ways of doing things, not just with nconvert but in general. It's about reducing the trial and error detours and taking out the "random quirks" which of course all have their explanation - as I always find out LATER, such as trailing spaces or quotes handling.

But to keep all those rules in mind in the heat of the moment when something doesn't work, to narrow it down to one of the many possible causes - that's a tall order. Under stress and time pressure it's much easier to use tools that call less atttention to themselves, where I can be sure it's not a silly syntax mistake I am dealing with.

I think I will shift my focus towards AHK, with the added advantage of multi-threading and other niceties. I am learning much faster from your scripts that use this approach, where you seem to pass on the heavy lifting to AHK. Less frustrating and yet challenging enough. I still need advanced stuff like RegEx - but even that seems more mainstream. Boosts motivation when you harvest synergy effects, when the same syntax applies elsewhere.

@totmad
thanks for the nconvert script - will adjust it to my paths and try it out later.

Stef123

Re: Check if paperfolder active

Post by Stef123 »

@totmad1
I modified paths and parameters in your nconvert script and got it to work :beer: - will use your script as a template for other cmd tools that process multiple selections.

@highend,
your last version works, the one with ""cmd"" in double quotes. I just rewrote my quotes-guideline (once again) - now it's "Put every component in it's own pair of dual double quotes, no matter how short, no matter if it contains spaces or not. But only if the component does not qualify as a parameter. Never put parameters inside quotes. Then frame the whole thing in double quotes. Frame in single quotes only when you don't want XY parameters resolved but literally rendered."
Curious how well I will fare with this version.

Post Reply