GET-IT: TEAMS DAY | 1-Day Free Virtual Conference all about Teams. Here on Petri.com - 8/12/20 GET-IT: TEAMS DAY - 8/12/20

Good ol for do loop

Home Forums Scripting DOS Command Shell Good ol for do loop

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    meksiki
    Member
    #164353

    Hi folks!

    So basically I have a .txt file that contains 2 lines. I want to take line 2 of the file and set it as a variable

    I’m typing this in the command prompt to test it out the code, but it’s not printing anything out

    For /f “skip=1 %G IN (“file.txt”) do @echo %G
    [/CODE] To implement this in my batch file I tried this, but it’s a no go

    [CODE]
    FOR /f “skip=1” %%G IN (“textfile.txt”) do (
    %%G=%variable%
    echo %variable%
    )
    [/CODE]
    it’s not printing anything. My prompt is in the same folder s the file (c:users[I]user[/I]) I’m sure my code is missing something, but not really sure what. If you somebody could point me in the right direction I’d greatly appreciate it

    Edit:
    Line 2 of the text file has no spaces, it’s actually the SID of a user profile[CODE]
    For /f “skip=1 %G IN (“file.txt”) do @echo %G
    [/CODE] To implement this in my batch file I tried this, but it’s a no go

    FOR /f “skip=1” %%G IN (“textfile.txt”) do (
    %%G=%variable%
    echo %variable%
    )
    [/CODE]
    it’s not printing anything. My prompt is in the same folder s the file (c:users[I]user[/I]) I’m sure my code is missing something, but not really sure what. If you somebody could point me in the right direction I’d greatly appreciate it

    Edit:
    Line 2 of the text file has no spaces, it’s actually the SID of a user profile[CODE]
    FOR /f “skip=1” %%G IN (“textfile.txt”) do (
    %%G=%variable%
    echo %variable%
    )
    [/CODE]
    it’s not printing anything. My prompt is in the same folder s the file (c:usersuser) I’m sure my code is missing something, but not really sure what. If you somebody could point me in the right direction I’d greatly appreciate it

    Edit:
    Line 2 of the text file has no spaces, it’s actually the SID of a user profile

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.