How to convert argument list to skip first argument?
%* = "C:\7-Zip Test\" "File&Test 1.txt" "File&Test 2.txt" "File&Test 3.txt"
After conversion, this should be the argument list
%filelist% = "File&Test 1.txt" "File&Test 2.txt" "File&Test 3.txt"
Please help
How to convert argument list to skip first argument?
Moderator: DosItHelp
-
- Posts: 31
- Joined: 08 Sep 2017 06:10
-
- Posts: 31
- Joined: 08 Sep 2017 06:10
Re: How to convert argument list to skip first argument?
I need a solution with a FOR loop without SHIFT
Re: How to convert argument list to skip first argument?
How do you get this list?
Output:
viewtopic.php?p=38525#p38525
Saso
Code: Select all
@echo off
echo %*
set par_list=&rem
:0
shift
set par_list=%par_list% %1
if not "%2"=="" goto :0
echo %par_list%
Code: Select all
c:\>some_bat.cmd "a" "b" "c" "d"
"a" "b" "c" "d"
"b" "c" "d"
c:\>
Saso
Re: How to convert argument list to skip first argument?
Code: Select all
@echo off & setlocal EnableDelayedExpansion
set skip=
set args=
for %%p in (%*) do (
if not defined skip (
set "skip=true"
) else if not defined args (
set "args=%%p"
) else (
set "args=!args! %%p"
)
)
-
- Posts: 175
- Joined: 17 Jan 2016 23:55
Re: How to convert argument list to skip first argument?
You could do it this way
Code: Select all
@echo off & setlocal enableDelayedExpansion
call :function "one" "two" "three" "four" "five"
pause & exit
:function
set /a "SKIP=1", "args=0"
set /a "start=1 + skip"
for %%i in (%*) do (
set /a "args+=1"
set "func[!args!]=%%~i"
)
for /l %%i in (%start%,1,%args%) do (
echo !func[%%i]!
)
goto :eof