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

Author Topic: need help, should be simple... something like tokens  (Read 9327 times)

0 Members and 2 Guests are viewing this topic.

Redd4

    Topic Starter


    Rookie

    • Experience: Familiar
    • OS: Windows XP
    Re: need help, should be simple... something like tokens
    « Reply #15 on: January 30, 2013, 02:10:58 AM »
    i need to to proceed to step two, even if it finds no tokens during step 1

    but i dont know how to do that. is there a continue command?

    Lemonilla



      Apprentice

    • "Too sweet"
    • Thanked: 70
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: need help, should be simple... something like tokens
    « Reply #16 on: January 30, 2013, 04:25:49 AM »
    You may want to put an exit before ':builderror' as of now it will display that even without an error.

    Another thing, if it errors on the 2nd 'rd' the first time you run, it will always error, as the first 'rd's target is gone. I don't know if you wanted to do that or not.

    Code: [Select]
    for /f "tokens=2,3" %%a in (' SYSTEMINFO ^|find /i "broadcom" ') do set "var=%%b"
    ::If var is empty then there were no tokens found
    if "%var%"=="" goto builderror
    and I do believe you need an opening '(' after "do" if you plan on including other stuff in your for loop.
    Quote from: patio
    God Bless the DOS Helpers...
    Quote
    If it compiles, send the files.

    foxidrive



      Specialist
    • Thanked: 268
    • Experience: Experienced
    • OS: Windows 8
    Re: need help, should be simple... something like tokens
    « Reply #17 on: January 30, 2013, 06:57:30 PM »
    I'm not sure of your question but check the additions in blue

    for /f "tokens=2,3" %%a in (' SYSTEMINFO ^|find /i "broadcom" ') do set "var=%%b"

    IF not defined var (
      goto builderror
    )

    echo I like cats and %var%



    RD /S /q  C:\CA\repositorydriver\directoryA

    IF ERRORLEVEL 1 (
      goto builderror
    )

    RD /S /q  C:\CA\repositorydriver\directoryB

    IF ERRORLEVEL 1 (
      goto builderror
    )

    goto :EXIT


    :builderror
    echo *** An error has occured executing clearRegistry.bat 
    pause

    :exit

    Lemonilla



      Apprentice

    • "Too sweet"
    • Thanked: 70
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: need help, should be simple... something like tokens
    « Reply #18 on: January 30, 2013, 07:40:21 PM »
    Was finally able to run some tests, scratch what I said about if the first target is not there.
    Code: [Select]
    C:\Users\Lemonilla>rd AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    The system cannot find the file specified.

    C:\Users\Lemonilla>echo %errorlevel%
    0

    I did not know about 'if defined', very useful. Thanks foxidrive!
    Quote from: patio
    God Bless the DOS Helpers...
    Quote
    If it compiles, send the files.

    Redd4

      Topic Starter


      Rookie

      • Experience: Familiar
      • OS: Windows XP
      Re: need help, should be simple... something like tokens
      « Reply #19 on: February 01, 2013, 02:32:05 AM »
      thanks guys, really though! still plugging away at getting it right, was nice to log in and see more refinements

      Redd4

        Topic Starter


        Rookie

        • Experience: Familiar
        • OS: Windows XP
        Re: need help, should be simple... something like tokens
        « Reply #20 on: February 01, 2013, 02:36:48 AM »
        Lemonilla your version worked also, -  if "%var%"=="" goto builderror -
        was better than my "if errorlevel" - which didnt work in that case

        Squashman



          Specialist
        • Thanked: 134
        • Experience: Experienced
        • OS: Other
        Re: need help, should be simple... something like tokens
        « Reply #21 on: February 01, 2013, 08:29:44 PM »
        hey all. Thanks for explaining that Foxidrive.  It seems this site is one of the only resources for learning msdos on the net.

        you are not learning msdos. msdos is an operating system. you are learning batch scripting. plenty of places to get help for batch scripting.

        rob vanderwoude has a great website as well as eric phelps.
        stack overflow is a great forum as is dostips.com, techguy and computer hope.

        Redd4

          Topic Starter


          Rookie

          • Experience: Familiar
          • OS: Windows XP
          Re: need help, should be simple... something like tokens
          « Reply #22 on: February 05, 2013, 06:43:41 AM »
          cheers Squashman, good to know, going forward, seems im not finished learning by a longshot.