Page 1 of 1

Move/Create a text file into a folder

Posted: 11 Sep 2011 19:59
by kami
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

Re: Move/Create a text file into a folder

Posted: 12 Sep 2011 04:07
by trebor68
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

Re: Move/Create a text file into a folder

Posted: 17 Sep 2011 21:32
by kami
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