Batch Programming Writing to Text file

Channel:
Subscribers:
11,500
Published on ● Video Link: https://www.youtube.com/watch?v=wnjLPWvS7Hg



Duration: 9:48
758 views
11


I can't use brackets, so bracket = -b for single bracket
-bb is for double brackets

Writing to text file
echo Hello World -bb Textfilename.txt (no spaces)
echo Hello World -bb "Text File Name.txt" (spaces)
echo %Input% -bb "%Input%.txt" (spaces)

Write text file in another directory
echo Message -bb "Drive:\filepath\subdirectory\textfile.txt"
echo %Input% -bb "Drive:\filepath\subdirectory\%input%.txt"
(no quotations are necessary in file path for %input%.)
echo %input% -bb "\\Network Computer\directory\subdirectory\%Input%.txt"

Sample 1
@echo off
Title Txt file
(echo First line) -b A.txt
(echo 2nd line) -bb A.txt
echo 3rd line -bb A.txt
echo 4th line -bb A.txt
echo 5th line -bb A.txt
echo 6th line -bb A.txt

Output:
echo First line
echo 2nd line
echo 3rd line
echo 4th line
echo 5th line
echo 6th line

Sample 2:
@echo off

echo Type in your text in here.

:start

set /p P=Type in here, and press enter:

echo enter the 2nd line.
set /p A=Enter 2nd line:

echo %P% -b B.txt
echo %A% -bb A.txt

Sample 3:

@echo off
cls
:start
echo 1. Enter a message
echo 2. exit
set /p K=Enter a message and press enter:
if %K% LEQ 2 (
goto Part_%K%
) else (
goto start)

:Part_1
goto next
:Part_2
exit


:next
echo Enter a Filename
set /p FN=Type and enter:
echo enter a message
set /p M=Type and enter:

echo %M% -bb"%FN%".txt
goto start

Sample 4:

@echo off
:start
cls

echo 1- Enter a message
echo 2- exit
echo.
set /p K= Make selection:
if %K% LEQ 2 (
goto Part_%K%
) else (
goto start
)

:Part_1
cls
echo 1- sent to Tom
echo 2- sent to Jill
set /p Select=Make selection and press enter:
if %Select% LEQ 2 (
goto L_%Select%
) else (
goto next
)
:L_1
echo Enter a Filename
set /p FN=Type and enter:
echo enter a message
set /p MTOM=Enter a message:
echo %MTOM% -bb"E:\Test\Tom\%FN%.txt"
goto start

:L_2
echo Enter a Filename
set /p FN=Type and enter:
echo enter a message
set /p MJILL=Enter a message:
echo %MJILL% -bb"E:\Test\Jill\%FN%.txt"
goto start


:Part_2
exit

I have a website which contains the links to all my batch programming videos.

https://he-1000-1975.com/video-directory/#F

If you found this video helpful, you can donate to my paypal account. It's optional. https://www.paypal.me/Ace1000ks1975