Batch File Help

H

Henry

I want to create a dos batch file in XP that will ask the user to input a
number of 4 characters then use that input to rename and copy files.

e.g. in unix I would have something simple like;

echo "Please enter number"
read $x
mv c:\elephant c:\eleph$xant



--
~~~~~~~~~~
All the best,

Henry
~~~~~~~~~~
 
G

Guest

Henry said:
I want to create a dos batch file in XP that will ask the user to input a
number of 4 characters then use that input to rename and copy files.

e.g. in unix I would have something simple like;

echo "Please enter number"
read $x
mv c:\elephant c:\eleph$xant



--
~~~~~~~~~~
All the best,

Henry
~~~~~~~~~~
What files do you want to rename and copy? Where are these files? This is
what I came up with so far, but this batch doesn't rename or copy any files...

@echo off
setlocal
:top
for /l %%i in (1,1,5) do echo.
set /p "answer=Please enter a 4 digit number: "
if "%answer%"=="" cls & goto top
if %answer%==0000 cls & goto top
set cnt=0
:loop
set /a cnt+=1
call set var=%%answer:~0,%cnt%%%
if not "%var%"=="%answer%" goto loop
if %cnt% gtr 4 goto error
if %cnt% lss 4 goto error
set /a check_num=%answer%+0
if %errorlevel%==9167 goto error
if %check_num%==0 goto error

::ren "[drive:][path]filename1" %answer%
::copy /?
goto :end

:error
cls
for /l %%i in (1,1,3) do echo.
echo You did not enter a 4 digit number. Please try again...
goto top

:end
cls
for /l %%i in (1,1,3) do echo.
echo You entered %answer%
pause >nul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top