script to open multiple files paths from clipboard

Discuss and share scripts and script files...
Post Reply
kotlmg
Posts: 321
Joined: 30 Jun 2010 17:14

script to open multiple files paths from clipboard

Post by kotlmg »

hello sir,
i am able to open selected pdf files using xyplorer script using
OpenWith """C:\Foxit PhantomPDF editor 5210201\Foxit PhantomPDF.exe"" <items>";

assuming clipboard contains the path of files as
D:\10th class\books\NCERT_CLASS_10_MATHEMATICS_ENGLISH.pdf
D:\10th class\books\NCERT_CLASS_10_HINDI_KRITIKA_2.pdf
D:\10th class\books\NCERT_CLASS_10_ENGLISH_FIRST_FLIGHT.pdf
D:\10th class\books\NCERT_CLASS_10_MATHEMATICS_ENGLISH.pdf

how to modify the above script to open mulitple files using the path in the clipboard?
i tried
OpenWith """C:\Foxit PhantomPDF editor 5210201\Foxit PhantomPDF.exe"" <clipboard>"; but it is not working.

could you please help?

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

Re: script to open multiple files paths from clipboard

Post by highend »

By reformatting the clipboard content to a list of quoted, space-separated items?
One of my scripts helped you out? Please donate via Paypal

kotlmg
Posts: 321
Joined: 30 Jun 2010 17:14

Re: script to open multiple files paths from clipboard

Post by kotlmg »

could you please write the code sir?

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

Re: script to open multiple files paths from clipboard

Post by highend »

You need quote() | trim() and replace(), go and read their documentation and write it yourself?
One of my scripts helped you out? Please donate via Paypal

kotlmg
Posts: 321
Joined: 30 Jun 2010 17:14

Re: script to open multiple files paths from clipboard

Post by kotlmg »

some how i made it to work with the following code.
"open from clipboard"

set $SelectedItems, <clipboard>;
foreach($Item, $SelectedItems, "<crlf>") {
if($Item == ""){ break; }
else{

OpenWith """C:\Foxit PDF Editor Pro 2024.2.0.25138\FoxitPDFEditor.exe"" $Item";

}
}

kotlmg
Posts: 321
Joined: 30 Jun 2010 17:14

Re: script to open multiple files paths from clipboard

Post by kotlmg »

Code: Select all

"open from clipboard"
  
   set $SelectedItems, <clipboard>;
   foreach($Item, $SelectedItems, "<crlf>") {
      if($Item == ""){ break; }
      else{
         
         OpenWith """C:\Foxit PDF Editor Pro 2024.2.0.25138\FoxitPDFEditor.exe"" $Item";
	 
      } 
   }

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

Re: script to open multiple files paths from clipboard

Post by highend »

If FoxitPDFEditor.exe automatically skips items that don't exist, you're lucky because you aren't quoting them...

You are assigning the clipboard to a variable for no reason, you could also directly use it for the loop
foreach has a flag to skip empty items so the whole if ... else statement in the loop is unnecessary
Your openwith call is totally malformed (read the docs^^)

So you could have it written as (still without correct quoting or a fix for the openwith):

Code: Select all

"open from clipboard"
    foreach($Item, <clipboard>, <crlf>, "e") {
        OpenWith """C:\Foxit PDF Editor Pro 2024.2.0.25138\FoxitPDFEditor.exe"" $Item";
    }
And one way to do everything correctly:

Code: Select all

"open from clipboard"
    $items = replace(trim(<clipboard>, <crlf>), <crlf>, '" "');
    run """C:\Foxit PDF Editor Pro 2024.2.0.25138\FoxitPDFEditor.exe"" ""$items""";
One of my scripts helped you out? Please donate via Paypal

kotlmg
Posts: 321
Joined: 30 Jun 2010 17:14

Re: script to open multiple files paths from clipboard

Post by kotlmg »

thanks a lot sir.

Post Reply