Search found 6 matches

by chunter2
06 Oct 2014 10:17
Forum: DOS Batch Forum
Topic: If/Else using data from a file?
Replies: 13
Views: 7552

Re: If/Else using data from a file?

this worked...it put the id on a new line If you started a file by typing a username on a line and didn't hit enter, the first line you output to that file from a batch file would append to the last line but would also end the line with a crlf so the next time you run the batch file you would not h...
by chunter2
03 Oct 2014 14:50
Forum: DOS Batch Forum
Topic: If/Else using data from a file?
Replies: 13
Views: 7552

Re: If/Else using data from a file?

ok, this helped me out: I just now learned that DOS does not have a line break. So, I just first, wrote to an empty line using echo. and then wrote the username. echo.>>"C:\Users\test\Desktop\test\list.txt" echo %USERNAME%>>"C:\Users\test\Desktop\test\list.txt" this worked...it p...
by chunter2
03 Oct 2014 13:31
Forum: DOS Batch Forum
Topic: If/Else using data from a file?
Replies: 13
Views: 7552

Re: If/Else using data from a file?

You are echoing a space to the output file. The findstr command is checking to make sure the username matches at the beginning of the line and at the end of the line. Since you are echoing an extra space to the output file it doesn't match. How do you prevent adding the extra space? Do I need the >...
by chunter2
03 Oct 2014 13:02
Forum: DOS Batch Forum
Topic: If/Else using data from a file?
Replies: 13
Views: 7552

Re: If/Else using data from a file?

actually hold on... I created a file add.bat it contains this: echo %USERNAME% >> "C:\Users\test\Desktop\test\list.txt" basically, I'm writing the username to the list.txt file....but when i do....and then run that code you gave me to search for it....it says its not there. But, when I han...
by chunter2
03 Oct 2014 11:41
Forum: DOS Batch Forum
Topic: If/Else using data from a file?
Replies: 13
Views: 7552

Re: If/Else using data from a file?

Squashman wrote:How about conditional execution instead.

Code: Select all

findstr /B /E "%USERNAME%" "list.txt" >nul 2>&1 &&(xcopy C:\test.txt C:\work\) ||(xcopy C:\test2.txt C:\work\)



that's an even better solution. Thank you!
by chunter2
03 Oct 2014 10:28
Forum: DOS Batch Forum
Topic: If/Else using data from a file?
Replies: 13
Views: 7552

If/Else using data from a file?

I would like to do an if/else statement using data from a text file. I will have a file list.txt It will have a list of IDs.... ex) 312906 714598 212375 I want to create an if/else statement that checks to see if the current windows user (%USERNAME%) is listed in the list.txt file If the current win...