Computer Hope
Microsoft => Microsoft DOS => Topic started by: Palwinder on November 11, 2004, 07:20:25 AM
-
Hi Everyone :)
I am fairly new in batch file scripting. I have a problem that i have been working opn since last 5 days but I cannot figure how to do it. ???
I want to create a bach file. Lets say it is named extra2.bat.
Then it should use replaceable parameters so that the user may choose what file extensions to display.
Allow any existing files to be copied to a new file that the user names.
Display the contents of the newly created file.
Provides a way for the user to change their mind and not to delete any files i.e. ask them for confirmation.
-
Use a set of batch files and a menu text. extra2.bat would simply be a command to start the thing off:
@echo off
cls
type menu2.txt
Menu2.txt would be a list of the available commands:
1) Copy file to new name, type 1 oldpath\oldname.ext newpath\newname.ext
2) Display file, type 2 path\name.ext
3) Confirm selection, type 3
Then you make up batch files 1.bat, 2.bat, and 3.bat.
1.bat is a sample:
@echo off
if exist %2 goto error
copy %1 %2
goto end
:error
echo Destination file already exists, choose another destination name. Press a key.
pause
:end
extra2
You'll figure out the other two...