openwith only <item>
-
nerdweed
- Posts: 648
- Joined: 25 Feb 2012 07:47
- Location: XY64 Latest Beta , Win 11, 96dpi, 100%
openwith only <item>
A quick question. How does the openwith only variable <item> pass the selected item lists
This works fine
openwith ("""$WinRAR"" x -- <items> ""<curpath>""", m) ;
Whereas this doesn't
openwith ("""$WinRAR"" x -- $Files ""<curpath>""", m) ;
I have tried with $Files as (mentioned with the required quoting). The filenames are full paths and can contain spaces
1. ""File1" "File2" ... "Filen""
2. "File1 File2 .. Filen" //Though knew this wouldn't work
Why?
$Files is a subset of the selected items
This works fine
openwith ("""$WinRAR"" x -- <items> ""<curpath>""", m) ;
Whereas this doesn't
openwith ("""$WinRAR"" x -- $Files ""<curpath>""", m) ;
I have tried with $Files as (mentioned with the required quoting). The filenames are full paths and can contain spaces
1. ""File1" "File2" ... "Filen""
2. "File1 File2 .. Filen" //Though knew this wouldn't work
Why?
$Files is a subset of the selected items
-
highend
- Posts: 14953
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: openwith only <item>
put a step; before your command and see how the $files resolves?
One of my scripts helped you out? Please donate via Paypal
-
nerdweed
- Posts: 648
- Joined: 25 Feb 2012 07:47
- Location: XY64 Latest Beta , Win 11, 96dpi, 100%
Re: openwith only <item>
I did and it resolves either as mentioned in 1 and 2 (I meant them to be the resolved ones rather than the written ones).
I forgot to mention that, using that command with $Files opens up the base folder in Windows Explorer rather than extracting the files.
With <items> the files are properly extracted.
P.S. Not in front of my code, so might have slightly mistyped.
The step dialog doesn't show the resolved <items> so not sure where I am going wrong.1. """""" . """File1""" . """File2""" ... . """Filen""" . """"""
resolves to
""File1" "File2" ... "Filen""
2. $Files = """" . "File1 File2 ... File n" . """"
resolves to
"File1 File2 .. Filen"
I forgot to mention that, using that command with $Files opens up the base folder in Windows Explorer rather than extracting the files.
With <items> the files are properly extracted.
P.S. Not in front of my code, so might have slightly mistyped.
-
highend
- Posts: 14953
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: openwith only <item>
1. If your $files resolves to something like:
"D:\a.txt D:\b.txt"
instead of
"D:\a.txt" "D:\b.txt"
it won't work (with Winrar).
So you're doing something wrong when you build that $files variable.
But... you don't post your code so how should we know what you're doing there...
Apart from that you should put $files in double quotes.
Apart from that, openwith is no function with a return value.
And at last...
To see how <items> are resolved (they are quoted for each item separately like:
"D:\a.txt" "D:\b.txt" etc.
use a batch file with:
and call it like:
"D:\a.txt D:\b.txt"
instead of
"D:\a.txt" "D:\b.txt"
it won't work (with Winrar).
So you're doing something wrong when you build that $files variable.
But... you don't post your code so how should we know what you're doing there...
Apart from that you should put $files in double quotes.
Code: Select all
openwith ("""$WinRAR"" x -- ""$Files"" ""<curpath>""", m) ;Code: Select all
openwith """$WinRAR"" x -- ""$Files"" ""<curpath>""", m ;To see how <items> are resolved (they are quoted for each item separately like:
"D:\a.txt" "D:\b.txt" etc.
use a batch file with:
Code: Select all
echo %*
pauseCode: Select all
openwith """<full path to the batch file.bat>"" x -- <items> ""<curpath>""", m ;One of my scripts helped you out? Please donate via Paypal
-
nerdweed
- Posts: 648
- Joined: 25 Feb 2012 07:47
- Location: XY64 Latest Beta , Win 11, 96dpi, 100%
Re: openwith only <item>
Code: Select all
"Extract"
$ext = ".*\.zip|.*\.rar|.*\.7z$" ;
$Files = """""" . Replace(RegExMatches(Get("SelectedItemsPathNames"), $ext, "<crlf>"),"<crlf>", """ """) . """""" ;
If ($Files != "") {
openwith ("""$WinRAR"" x -- $Files ""<curpath>""", m) ;
}
Edit: I doubled the quotes inside the quotes, had to do it twice as the quotes are present again.
It triggers WinRAR but it doesn't extract anything though$Files = """""" . Replace(RegExMatches(Get("SelectedItemsPathNames"), $ext, "<crlf>"),"<crlf>", """"" """"") . """""" ;
-
PeterH
- Posts: 2827
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: openwith only <item>
You know that in XY """""" is the same as '""' ?
Double quotes in double quotes must be doubled, double quotes in single quotes not.
Variables in single quotes are taken as literal - but there are none
Same for """ """
you may use '" "'
So compare:
And I'm not sure: do syntax rules request that <crlf> must be quoted?
Double quotes in double quotes must be doubled, double quotes in single quotes not.
Variables in single quotes are taken as literal - but there are none
Same for """ """
So compare:
Code: Select all
$Files = """""" . Replace(RegExMatches(Get("SelectedItemsPathNames"), $ext, "<crlf>"),"<crlf>", """ """) . """""" ;
$Files = '""' . Replace(RegExMatches(Get("SelectedItemsPathNames"), $ext, "<crlf>"),"<crlf>", '" "') . '""' ;
-
nerdweed
- Posts: 648
- Joined: 25 Feb 2012 07:47
- Location: XY64 Latest Beta , Win 11, 96dpi, 100%
Re: openwith only <item>
Thanks for reminding about single quotes. Did that now.
Quoting <crlf>, I often do it since Don once said quoting would ensure compatibility (though not explicitly for this).
Lets, leave the remaining code and parsing of $Files aside for now.

Quoting <crlf>, I often do it since Don once said quoting would ensure compatibility (though not explicitly for this).
Lets, leave the remaining code and parsing of $Files aside for now.
Even this doesn't work. Though it invokes WinRAR, the below message is displayedopenwith """$WinRAR"" x -- ""D:\ToggleCdolumns.zip"" ""<curpath>""", m ;
This isn't true because the same file extracts just fine when <items> is used.! D:\ToggleCdolumns.zip: No files to extract
-
nerdweed
- Posts: 648
- Joined: 25 Feb 2012 07:47
- Location: XY64 Latest Beta , Win 11, 96dpi, 100%
Re: openwith only <item>
Can anyone repro this. It doesn't work with WinRAR, it says file is corrupt.
BandiZip extracts all files multiple times - once for each file passed.
<items> works ok.
BandiZip extracts all files multiple times - once for each file passed.
<items> works ok.
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: openwith only <item>
Does WinRAR allow eXtracting multiple files at once, like winrar x "archive1.rar" "archive2.zip" "extraction\path\"?
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
nerdweed
- Posts: 648
- Joined: 25 Feb 2012 07:47
- Location: XY64 Latest Beta , Win 11, 96dpi, 100%
Re: openwith only <item>
Yes, it does. <items> extracts its just fine.
And it fails even on passing a single file - it does open WinRAR but reports the file is corrupt. Like Highend suggested, I checked the parameters using a bat file and they match. Don't know whats causing this.
To Summarize,
1. The below reports corrupt file in WinRAR
openwith """$WinRAR"" x -- ""D:\ToggleCdolumns.zip"" ""<curpath>""", m ;
2. This works fine when, <items> is D:\ToggleCdolumns.zip
openwith """$WinRAR"" x -- <items> ""<curpath>""", m ;
Tried it with BandiZip, as well for two items D:\File1.zip and D:\File2.zip
3. It extracts with BandiZip but both files are extracted twice. Workd well with only on archive
openwith """$BandiZip"/extract_autodest ""<curpath>"" ""D:\File1.zip"" ""D:\File2.zip"""
4. Withe <items> it works fine and extracts only once
openwith """$BandiZip"/extract_autodest ""<curpath>"" <items>"
And it fails even on passing a single file - it does open WinRAR but reports the file is corrupt. Like Highend suggested, I checked the parameters using a bat file and they match. Don't know whats causing this.
To Summarize,
1. The below reports corrupt file in WinRAR
openwith """$WinRAR"" x -- ""D:\ToggleCdolumns.zip"" ""<curpath>""", m ;
2. This works fine when, <items> is D:\ToggleCdolumns.zip
openwith """$WinRAR"" x -- <items> ""<curpath>""", m ;
Tried it with BandiZip, as well for two items D:\File1.zip and D:\File2.zip
3. It extracts with BandiZip but both files are extracted twice. Workd well with only on archive
openwith """$BandiZip"/extract_autodest ""<curpath>"" ""D:\File1.zip"" ""D:\File2.zip"""
4. Withe <items> it works fine and extracts only once
openwith """$BandiZip"/extract_autodest ""<curpath>"" <items>"
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: openwith only <item>
I just fetched WinRAR. I can confirm what you've reported.
Does this still extract twice if you stick a ,s,; at the end?nerdweed wrote:3. It extracts with BandiZip but both files are extracted twice. Workd well with only on archive
openwith """$BandiZip"/extract_autodest ""<curpath>"" ""D:\File1.zip"" ""D:\File2.zip"""
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
nerdweed
- Posts: 648
- Joined: 25 Feb 2012 07:47
- Location: XY64 Latest Beta , Win 11, 96dpi, 100%
Re: openwith only <item>
I didn't explicitly mention s as I believe that is the default mode. Will check it in a few hours by explicitly mentioning s for bandizip.
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: openwith only <item>
There's also a "," after the "s", which is supposed to give custom filelist (in this case it's rendered empty).
My logic is that because multiple files are selected, XY is running the command twice, for both files. Since the command already apparently includes all files, let's give it an empty filelist.
Can't confirm tho'.
My logic is that because multiple files are selected, XY is running the command twice, for both files. Since the command already apparently includes all files, let's give it an empty filelist.
Can't confirm tho'.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
nerdweed
- Posts: 648
- Joined: 25 Feb 2012 07:47
- Location: XY64 Latest Beta , Win 11, 96dpi, 100%
Re: openwith only <item>
It gives a No archives found error if I pass it as the last parameter or no files.
No joy with ,s, / ,m, /,, either.
Regardless of Bandizip being called multiple times, WinRar is called only once unless I pass ,m, parameter.
No joy with ,s, / ,m, /,, either.
Regardless of Bandizip being called multiple times, WinRar is called only once unless I pass ,m, parameter.
-
nerdweed
- Posts: 648
- Joined: 25 Feb 2012 07:47
- Location: XY64 Latest Beta , Win 11, 96dpi, 100%
Re: openwith only <item>
Don, would you be able to help with this.
XYplorer Beta Club