Computing.Net > Forums > Disk Operating System > DOS Batch input

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

DOS Batch input

Reply to Message Icon

Name: Gary
Date: March 28, 2002 at 11:29:32 Pacific
Comment:

I need to write a simple batch program to ask a user to input a file name, then to use that file name in a copy statement..

example:
Input file name: filename
copy c:\temp\filename g:\temp\filename

how do I do this???



Sponsored Link
Ads by Google

Response Number 1
Name: Laurence
Date: March 29, 2002 at 12:59:30 Pacific
Reply:


See my FAQ.


0

Response Number 2
Name: Secret_Doom
Date: March 29, 2002 at 20:55:44 Pacific
Reply:

This shows how to get user input and send to %input% variable:

For Win9x/DOS6.22:

@echo off
echo Type in input
echo.>%temp%.\$$tmp.bat
FC con nul /lb1 /n |FIND "1:" >> %temp%.\$$tmp.bat
echo e100'set input='>%temp%.\$$tmp.dat
echo w>>%temp%.\$$tmp.dat
echo q>>%temp%.\$$tmp.dat
debug %temp%.\$$tmp.bat < %temp%.\$$tmp.dat > nul
call %temp%.\$$tmp.bat
for %%d in (tmp.bat tmp.dat) do if exist %temp%.\$$%%d del %temp%.\$$%%d
echo INPUT="%INPUT%"

!!! Watch out for line wrapping !!!

For NT systems:

set /p input=Type input:

The Win9x method does NOT include checking for errors on input. For further information, view my FAQ.

After getting user's input to a variable, simply do:

copy c:\temp\%input% g:\temp\%input%

HTH

-- Secret_Doom - Leonardo Pignataro --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 3
Name: gary
Date: April 1, 2002 at 16:01:34 Pacific
Reply:

this works except for a space in my file name. here is an example:

input=filename.ext
copy g:\temp\ filename.ext c:\temp\...
^
where does this space come form????


0

Response Number 4
Name: Secret_Doom
Date: April 2, 2002 at 19:29:12 Pacific
Reply:

The problem is this f***ing forum!
Note the following line:

echo e100'set input='>%temp%.\$$tmp.dat

There are _TWO_ spaces between "set" and "input" !

That will do it.

-- Secret_Doom - Leonardo Pignataro --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 5
Name: John
Date: April 5, 2002 at 03:07:14 Pacific
Reply:

I've tried all of the above options for taking a user input and using it in a filename or copy command but keep getting out of environment errors, anyone any ideas?


0

Related Posts

See More



Response Number 6
Name: [-LøL-]
Date: July 17, 2002 at 23:58:43 Pacific
Reply:

I read sumwhere in a PC mag that u can use %i as input (eg in my ping bomber that i tried: PING %i l 65500 n 10000 didnt work)... i think u could use that sumhow :S try it... If not, add me 2 messenger and use VB ;)


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: DOS Batch input

Inputing windows text into DOS batch fil www.computing.net/answers/dos/inputing-windows-text-into-dos-batch-fil/6335.html

DOS Batch - Accepting User input to system Variable www.computing.net/answers/dos/dos-batch-accepting-user-input-to-system-variable/658.html

Dos/batch password blanking www.computing.net/answers/dos/dosbatch-password-blanking/11332.html