This is How you Write/Load text on/from a file (CMD)

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Ranguna173
Posts: 104
Joined: 28 Jul 2011 17:32

This is How you Write/Load text on/from a file (CMD)

#1 Post by Ranguna173 » 16 Aug 2011 09:36

Hello everyone!!

I've already made some topics about this but here is the final answer! (I think)

Everyone can understand these two codes, they are really easy to understand.



Write text:

Code: Select all

echo This is the first Line!>%filehere%
echo This is the second Line!>>%filehere%
echo And this is the third and final Line!>>%filehere%

(%filehere% is where you put the path of the file)



Loading text:

Code: Select all

< %filehere% (
  set /p line1=
  set /p line2=
  set /p line3=
)

(%filehere% is where you put the path of the file)
(You can add as much line has you want, This one only has three)
(I got this code from this topic)



Now Here is a full code:

Code: Select all

@echo off
echo This batch will make a file called test.file
echo In it will be written 3 line of text, like this:
echo ----------------
echo Hello!
echo How are you?
echo Bye..
echo ----------------
pause

echo Hello!>test.file
echo How are you?>>test.file
echo Bye..>>test.file

cls
echo The test.file has been created!
echo You can now open it with a notepad to read what is inside.
echo Next this batch will read the test.file
echo and it will "echo" it.
pause

< test.file (
  set /p line1=
  set /p line2=
  set /p line3=
)

cls
echo This is what is inside the test.file :
echo.
echo ----------------
echo %line1%
echo %line2%
echo %line3%
echo ----------------
pause
echo That is all!
echo See! Easy, isn't it?
pause


So yeah, that is it!

If you want to add anything Just say the word!

Exouxas
Posts: 34
Joined: 01 Sep 2011 12:52

Re: This is How you Write/Load text on/from a file (CMD)

#2 Post by Exouxas » 01 Sep 2011 12:59

I freaking LOVE you for this, you have no idea how much I have been looking for it!

My script just got about 35% better :D

By the way, when I'm 'done' with my script I can post it if you want, just for you! (exclusive beta tester :D)

Ranguna173
Posts: 104
Joined: 28 Jul 2011 17:32

Re: This is How you Write/Load text on/from a file (CMD)

#3 Post by Ranguna173 » 25 Sep 2012 15:14

Exouxas wrote:I freaking LOVE you for this, you have no idea how much I have been looking for it!

My script just got about 35% better :D

By the way, when I'm 'done' with my script I can post it if you want, just for you! (exclusive beta tester :D)



Sorry for the late reply, but alright, just send it to my mail: ranguna313616@hotmail.com

And you are very welcome :D

Post Reply