Page 1 of 1
script to open multiple files paths from clipboard
Posted: 16 May 2024 20:43
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?
Re: script to open multiple files paths from clipboard
Posted: 16 May 2024 20:53
by highend
By reformatting the clipboard content to a list of quoted, space-separated items?
Re: script to open multiple files paths from clipboard
Posted: 16 May 2024 20:54
by kotlmg
could you please write the code sir?
Re: script to open multiple files paths from clipboard
Posted: 16 May 2024 21:10
by highend
You need quote() | trim() and replace(), go and read their documentation and write it yourself?
Re: script to open multiple files paths from clipboard
Posted: 16 May 2024 22:01
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";
}
}
Re: script to open multiple files paths from clipboard
Posted: 16 May 2024 22:02
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";
}
}
Re: script to open multiple files paths from clipboard
Posted: 16 May 2024 22:24
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""";
Re: script to open multiple files paths from clipboard
Posted: 17 May 2024 04:41
by kotlmg
thanks a lot sir.