You are not logged in.

#1 12 Dec 2015 00:28

Batcher
Member
Registered: 20 Jul 2015
Posts: 56

Set text file as user input

Is it possible to set the input of a user as a text file here is a code I have

@echo off 
Cls 
Set /p fpath=" enter file path"
If %content of text file% == "lots of text" goto here
:here

Thanks

Last edited by Batcher (12 Dec 2015 01:45)

Offline

#2 12 Dec 2015 11:37

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: Set text file as user input

Your specification is a bit on the vague side.

Can you describe your goal?

How would you quantify "lots of text"?  A particular number of lines?  High byte count?


cmd | *sh | ruby | chef

Offline

#3 12 Dec 2015 12:12

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Set text file as user input

You are setting a variable and not using it in the script. 
Your aim is indeed unclear...

Batcher wrote:
@echo off 
Cls 
Set /p fpath=" enter file path"
If %content of text file% == "lots of text" goto here
:here

Last edited by foxidrive (12 Dec 2015 12:13)

Offline

#4 12 Dec 2015 13:18

Batcher
Member
Registered: 20 Jul 2015
Posts: 56

Re: Set text file as user input

So let's say the text file contains the word false then the file will goto false

@echo off 
Cls 
Set /p fpath=" enter file path"
If %content of text file% == "lots of text" goto here
If %content of text file% ==false goto false
:here
Echo here
:false
Echo false

Last edited by Batcher (12 Dec 2015 13:19)

Offline

#5 12 Dec 2015 15:24

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Set text file as user input

find /i "false" <"file.txt" >nul && goto false

Offline

#6 12 Dec 2015 18:38

Batcher
Member
Registered: 20 Jul 2015
Posts: 56

Re: Set text file as user input

This works for drive but "false"may not be the only input is there a way to use ?'s to represent more characters?

Offline

#7 13 Dec 2015 13:21

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Set text file as user input

Batcher wrote:

This works for drive but "false"may not be the only input is there a way to use ?'s to represent more characters?

My code answered your question.

If you hide the details of the task then you will not get the most appropriate code and answer.

Last edited by foxidrive (13 Dec 2015 13:22)

Offline

#8 14 Dec 2015 09:08

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: Set text file as user input

As foxidrive says, you're not providing enough information to elicit meaningful help.

Describe in words what it is you are try to achieve.   Your pseudo code isn't really giving a great picture.

Provide real-world samples of input (anonymised if it contains anything sensitive) for the scenarios you want to cover and indicate what behaviours the different inputs should imply.


cmd | *sh | ruby | chef

Offline

#9 14 Dec 2015 16:27

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Set text file as user input

.

Last edited by foxidrive (14 Dec 2015 16:30)

Offline

Board footer

Powered by