Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: For loop Skip=%var%  (Read 3853 times)

0 Members and 1 Guest are viewing this topic.

Helpmeh

    Topic Starter


    Guru

  • Roar.
  • Thanked: 123
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Familiar
  • OS: Windows 8
For loop Skip=%var%
« on: May 21, 2009, 12:16:36 PM »
As the title depicts, in a for loop, I need skip to equal %var%. I tried for /f "skip=%var% delims=:" and for /f "delims=: skip=%var%" but it says that it was unexpected at this time.
Where's MagicSpeed?
Quote from: 'matt'
He's playing a game called IRL. Great graphics, *censored* gameplay.

Dias de verano

  • Guest
Re: For loop Skip=%var%
« Reply #1 on: May 21, 2009, 01:00:49 PM »
Since you didn't post your code or say what OS you are using we can't see where your problem is  ::)

However, this works

Code: [Select]
@echo off
echo 1:a>test.txt
echo 2:b>>test.txt
echo 3:c>>test.txt
echo 4:d>>test.txt
set var=2
for /f "tokens=1-2 skip=%var% delims=:" %%A in (test.txt) do (
echo %%A %%B
)

Code: [Select]
3 c
4 d
« Last Edit: May 21, 2009, 02:12:07 PM by Dias de verano »

Helpmeh

    Topic Starter


    Guru

  • Roar.
  • Thanked: 123
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Familiar
  • OS: Windows 8
Re: For loop Skip=%var%
« Reply #2 on: May 21, 2009, 05:52:44 PM »
Since you didn't post your code or say what OS you are using we can't see where your problem is  ::)

However, this works

Code: [Select]
@echo off
echo 1:a>test.txt
echo 2:b>>test.txt
echo 3:c>>test.txt
echo 4:d>>test.txt
set var=2
for /f "tokens=1-2 skip=%var% delims=:" %%A in (test.txt) do (
echo %%A %%B
)

Code: [Select]
3 c
4 d
Strange...it didn't work for me the first time.

say what OS you are using
It shows that beside my post...
Where's MagicSpeed?
Quote from: 'matt'
He's playing a game called IRL. Great graphics, *censored* gameplay.