Hi
How do I convert batch script arguments to pattern?
-ai!test1.7z -ai!test2.7z -ai!test3.7z
%1 = test1.7z
%2 = test2.7z
%3 = test3.7z
%* = test1.7z test2.7z test3.7z
Please help
How do I convert batch script arguments to pattern?
Moderator: DosItHelp
-
- Posts: 31
- Joined: 08 Sep 2017 06:10
Re: How do I convert batch script arguments to pattern?
If your input files are all unquoted, and do not contain spaces or other potentially poison characters, then you could probably simply use something like this:
Code: Select all
@Set "allinput=%*"
@Echo -ai!%allinput: = -ai!%
-
- Posts: 31
- Joined: 08 Sep 2017 06:10
Re: How do I convert batch script arguments to pattern?
For space don't work
%* =" test 1.7z" "test 2.7z" "test 3.7z"
%* =" test 1.7z" "test 2.7z" "test 3.7z"
Re: How do I convert batch script arguments to pattern?
Please don't try to disrespect me, I was very clear in my opening statement of my last response.
You've completely changed your input to include both spaces and doublequotes, and would obviously not therefore, be splitting the string on spaces, would you?
You'd be splitting on a doublequote space doublequote sequence:
You've completely changed your input to include both spaces and doublequotes, and would obviously not therefore, be splitting the string on spaces, would you?
You'd be splitting on a doublequote space doublequote sequence:
Code: Select all
@Set "allinput=%*"
@Echo -ai!%allinput:" "=" -ai!"%
-
- Posts: 31
- Joined: 08 Sep 2017 06:10
Re: How do I convert batch script arguments to pattern?
Hi
It doesn't work if names don't always have quotation marks.
Names without spaces do not have quotation marks (Total Commander %S).
ex
%* Test1.7z "Test 2.zip" Test2.rar
%1 Test1.7z
%2 "Test 2.zip"
%3 Test3.rar
Please help me
It doesn't work if names don't always have quotation marks.
Names without spaces do not have quotation marks (Total Commander %S).
ex
%* Test1.7z "Test 2.zip" Test2.rar
%1 Test1.7z
%2 "Test 2.zip"
%3 Test3.rar
Please help me
Re: How do I convert batch script arguments to pattern?
What about names with an ampersand and other special characters?PiotrMP006 wrote: ↑05 Apr 2021 02:27Names without spaces do not have quotation marks (Total Commander %S).
I am also concerned about your usage of the exclamation point. As that has special meaning in batch files as well when delayed expansion is enabled.
Re: How do I convert batch script arguments to pattern?
In total commander try using %P%S. Maybe this will help.
Or use %s (lowercase s).
Maybe better solution might be to use SHIFT in a loop to move parameters into variables.
Saso
Or use %s (lowercase s).
Maybe better solution might be to use SHIFT in a loop to move parameters into variables.
Saso