Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: writing multiline .txt  (Read 7247 times)

0 Members and 1 Guest are viewing this topic.

Fantini

  • Guest
writing multiline .txt
« on: August 24, 2007, 12:58:30 PM »
Hi, I'm kinda new in this, and I can't do something...

I want to something like this:

Echo Hello > Hello.txt

This work to me only when I'm working with a single line, but I want to create a Hello.txt with more than one line... for example:
Code: [Select]
Hello
World
Thank You

Sorry my bad English, it isn't my native lenguage  :), can anybody help me plz?
« Last Edit: August 24, 2007, 01:32:03 PM by Fantini »

diablo416

  • Guest
Re: writing multiline .txt
« Reply #1 on: August 24, 2007, 01:47:46 PM »

if i understand right , this is what you need..

echo hello >hello.txt
echo world >hello.txt
echo thank you >hello.txt

OR

or echo hello >hello.txt & echo world >hello.txt & echo thank you >hello.txt

Fantini

  • Guest
Re: writing multiline .txt
« Reply #2 on: August 24, 2007, 01:52:25 PM »
ok, a lot of thanks, but I have another problem now xD...

how can I do to white %hello% in a .bat file???
I want to create a .bat with that string :)

diablo416

  • Guest
Re: writing multiline .txt
« Reply #3 on: August 24, 2007, 01:57:46 PM »

just replace .txt with .bat

echo %hello% >>youbatchfile.bat






Fantini

  • Guest
Re: writing multiline .txt
« Reply #4 on: August 24, 2007, 02:04:56 PM »
the problem is when I use

echo %hello% >>youbatchfile.bat

when I open the .bat there isn't the %hello% line...

because %hello% is a variable, but i want to write literaly

diablo416

  • Guest
Re: writing multiline .txt
« Reply #5 on: August 24, 2007, 02:13:30 PM »
ok , instead type .. echo %^hello% >>yourbatchfile.bat

Fantini

  • Guest
Re: writing multiline .txt
« Reply #6 on: August 24, 2007, 02:17:02 PM »
it isn't work :-\

diablo416

  • Guest
Re: writing multiline .txt
« Reply #7 on: August 24, 2007, 02:23:18 PM »
what operating system do you use?  , try echo ^%^hello% >>batchfile.bat then

Fantini

  • Guest
Re: writing multiline .txt
« Reply #8 on: August 24, 2007, 02:25:36 PM »
sorry for not saying it, I'm using Win XP

that didn't work neither

contrex

  • Guest
Re: writing multiline .txt
« Reply #9 on: August 24, 2007, 02:32:31 PM »
you bunch of prannys.  ::)

Fantini, this is what you need to know.

To start a file, the first line uses one (1) of these symbols >

That is called creating the file.

The lines after that use two (2) of them like this >>

That is called appending to the file.

Like this.

echo hello > hello.txt
echo world >> hello.txt
echo Thank You >> hello.txt


Fantini

  • Guest
Re: writing multiline .txt
« Reply #10 on: August 24, 2007, 02:36:44 PM »
you bunch of prannys.  ::)

Fantini, this is what you need to know.

To start a file, the first line uses one (1) of these symbols >

That is called creating the file.

The lines after that use two (2) of them like this >>

That is called appending to the file.

Like this.

echo hello > hello.txt
echo world >> hello.txt
echo Thank You >> hello.txt


yeah ty, I alredy notice that xD!!, that's why I said it worked me... but my other problem... i don't know how to fix it >.<

diablo416

  • Guest
Re: writing multiline .txt
« Reply #11 on: August 24, 2007, 03:03:57 PM »

ive always used >> i never thought it made a difference , between > and >> .. ive never had a problem with it..   
after you set the variable .. what happense when you just type echo ^%^hello%? does it echo %hello% , or does it whatever your variable is set too?  .. what is your variable set to?   ,

Fantini

  • Guest
Re: writing multiline .txt
« Reply #12 on: August 24, 2007, 03:15:50 PM »
I have this .bat:

Code: [Select]
@echo off
ECHO.
set /p opcion=Ingresa el realmlist del servidor numero 2:
ECHO.
ECHO echo off > TarreWoW.bat
ECHO title TarreWoW Launcher V0.1 by Fantini >> TarreWoW.bat
ECHO cls >> TarreWoW.bat
ECHO :start >> TarreWoW.bat
ECHO ECHO. >> TarreWoW.bat
ECHO ECHO 1. TarreWoW >> TarreWoW.bat
ECHO ECHO 2. Servidor numero 2: %opcion% >> TarreWoW.bat
ECHO ECHO 3. Salir >> TarreWoW.bat
ECHO set /p choice=Elige el Servidor Porfavor:  >> TarreWoW.bat
ECHO if not '%choice%'=='' set choice=%choice:~0,1% >> TarreWoW.bat
ECHO if '%choice%'=='1' goto tarrewow >> TarreWoW.bat
ECHO if '%choice%'=='2' goto servidor 2 >> TarreWoW.bat
ECHO if '%choice%'=='3' goto end >> TarreWoW.bat
ECHO ECHO "%choice%" No es una opcion valida, intentalo denuevo porfavor >> TarreWoW.bat
ECHO ECHO. >> TarreWoW.bat
ECHO pause >> TarreWoW.bat
ECHO cls >> TarreWoW.bat
ECHO goto start >> TarreWoW.bat
ECHO :tarrewow >> TarreWoW.bat
ECHO ECHO SET realmlist tarrewow.getmyip.com > realmlist.*censored* >> TarreWoW.bat
ECHO goto end >> TarreWoW.bat
ECHO :servidor 2 >> TarreWoW.bat
ECHO ECHO SET realmlist %opcion% > realmlist.*censored* >> TarreWoW.bat
ECHO goto end >> TarreWoW.bat
ECHO :end >> TarreWoW.bat
ECHO cls >> TarreWoW.bat
ECHO ECHO. >> TarreWoW.bat
ECHO ECHO TarreWoW Launcher V0.1 by Fantini >> TarreWoW.bat
ECHO ECHO Gracias por preferirnos... >> TarreWoW.bat
ECHO ECHO. >> TarreWoW.bat
ECHO pause >> TarreWoW.bat
pause

and I want to make it look like this:

Code: [Select]
ECHO off
title TarreWoW Launcher V0.1 by Fantini
cls
:start
ECHO.
ECHO 1. TarreWoW
ECHO 2. Servidor numero 2: %opcion%
ECHO 3. Salir
set /p choice=Elige el Servidor Porfavor:
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto tarrewow
if '%choice%'=='2' goto servidor 2
if '%choice%'=='3' goto end
ECHO "%choice%" No es una opcion valida, intentalo denuevo porfavor
ECHO.
pause
cls
goto start
:tarrewow
ECHO SET realmlist tarrewow.getmyip.com > realmlist.*censored*
goto end
:servidor 2
ECHO SET realmlist %opcion% > realmlist.*censored*
goto end
:end
cls
ECHO.
ECHO TarreWoW Launcher V0.1 by Fantini
ECHO Gracias por preferirnos...
ECHO.
pause

but when I edit my TarreWoW.bat I see '' instead of '%choice%'

diablo416

  • Guest
Re: writing multiline .txt
« Reply #13 on: August 24, 2007, 04:33:51 PM »


ok i see what you mean... type this instead

echo if '^%^c^hoice%'=='3' goto terrewow >>tarrewow.bat


i tryed it in your code and it works,

contrex

  • Guest
Re: writing multiline .txt
« Reply #14 on: August 24, 2007, 04:38:12 PM »
Why are you doing it that way? Are you crazy?


Fantini

  • Guest
Re: writing multiline .txt
« Reply #15 on: August 24, 2007, 05:03:44 PM »
no,i'm not crazy, i'm just a noob

ghostdog74



    Specialist

    Thanked: 27
    Re: writing multiline .txt
    « Reply #16 on: August 24, 2007, 07:34:31 PM »
    I have this .bat:

    ...
    and I want to make it look like this:

    Code: [Select]
    ECHO off
    title TarreWoW Launcher V0.1 by Fantini
    cls
    :start
    ECHO.
    ECHO 1. TarreWoW
    ECHO 2. Servidor numero 2: %opcion%
    ECHO 3. Salir
    set /p choice=Elige el Servidor Porfavor:
    if not '%choice%'=='' set choice=%choice:~0,1%
    if '%choice%'=='1' goto tarrewow
    if '%choice%'=='2' goto servidor 2
    if '%choice%'=='3' goto end
    ECHO "%choice%" No es una opcion valida, intentalo denuevo porfavor
    ECHO.
    pause
    cls
    goto start
    :tarrewow
    ECHO SET realmlist tarrewow.getmyip.com > realmlist.*censored*
    goto end
    :servidor 2
    ECHO SET realmlist %opcion% > realmlist.*censored*
    goto end
    :end
    cls
    ECHO.
    ECHO TarreWoW Launcher V0.1 by Fantini
    ECHO Gracias por preferirnos...
    ECHO.
    pause

    but when I edit my TarreWoW.bat I see '' instead of '%choice%'

    Open notepad or any editor you like, key in the code above save it as some name you like, and you are ready to go.

    NDog

    • Guest
    Re: writing multiline .txt
    « Reply #17 on: August 26, 2007, 05:32:28 AM »
    you can go like this echo %%hello%%>file.txt
    or
    echo if '%%choice%%'=='3' goto terrewow >>tarrewow.bat

    ray.tomar

    • Guest
    Re: writing multiline .txt
    « Reply #18 on: August 28, 2007, 03:58:38 PM »
    Hi Fantini!

                 I request you to please try to use the COPY CON filename.txt command for storing text in multilines.

    For e.g. C:\>COPY CON filename.txt
    write some text here with multilines. When writing of files is over press CTRL+Z button to save the contents of file.

    You may also press F6 button instead of CTRL+Z.