Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
kami
- Posts: 9
- Joined: 11 Sep 2011 19:35
- Location: Jamaica
#1
Post
by kami » 11 Sep 2011 19:59
Hey. Can someone please help me with this.
I need to edit this code so directory of help files is created and all help files generated should be stores in the directory.
I can create the text file and the folder, but i cannot get the text file into the folder. lol
I need to get the text file to be created into the folder "Directory".
I also need to modify the program to check if a help file is already exists before creating one. If it exists display details
Code: Select all
@echo off
:start
echo. ____________
echo.
echo WELCOME
echo. ____________
echo.
set /p input=Please type your command:
%input% /? >%input%.txt
%input%.txt
md Directory
start Directory
pause
Thanks
Kami
-
trebor68
- Posts: 146
- Joined: 01 Jul 2011 08:47
#2
Post
by trebor68 » 12 Sep 2011 04:07
Please change the folder in this code, if you want. In the Example is this "C:\Test2\HelpFiles" where all the files are saved.
Here a solution:
Code: Select all
@echo off
set HelpFolder=C:\Test2\HelpFiles
if not exist "%helpfolder%\nul" md "%helpfolder%"
:: pushd "%helpfolder%"
cd "%helpfolder%"
:start
cls
echo.
echo WELCOME
echo -----------
echo.
set "input="
set /p input=Please type your command:
if exist %input%.txt goto :error1
%input% /? >%input%.txt
echo.
echo The help file "%input%.txt" has been created.
echo.
set /p input=If you want more? (Y/N)
if %input%#==y# goto :start
if %input%#==Y# goto :start
:: popd
goto :eof
:error1
echo.
echo Error: The file "%input%.txt" exists already.
echo Press a button to see the content.
echo.
pause
type %input%.txt | more
pause
goto :start
-
kami
- Posts: 9
- Joined: 11 Sep 2011 19:35
- Location: Jamaica
#3
Post
by kami » 17 Sep 2011 21:32
THANK YOU VERY MUCH!
I have also found an alternative to direct the text file into a folder
Code: Select all
@echo off
:start
echo. ____________
echo.
echo WELCOME
echo. ____________
echo.
set /p input=Please type your command:
md Directory
start Directory
[color=#FF0000] %input% /? >Directory\%input%.txt [/color]
%input%.txt
pause