Input Character in DOS

gouli -  
 labibleatari -
Bonjour,
I am trying to replace the string "pi" in a text file with the "carriage return" character
I would like to do this automatically with a batch script under Windows
I can't find how to define the carriage return (in my example I tried '\n'

The script:
for /f "delims=" %%a in ('type "%1"') do call :command "%%a"
goto :eof
:command

set line=%1
set line=%line:pi='\n'%
set line=%line:"=%
@echo %line% >> Nuevo/archivo.txt

Thank you for your help
Configuration: Windows 2000 Internet Explorer 6.0

10 answers

  1. Petitspirou
     
    The answer :)

    echo/
    2
  2. FichuCaractere
     
    @Petitspirou: Have you tested before saying nonsense about an old topic? ;)

    No successful tests on my end. Maybe it's due to the system? What are your configurations used? Sure, the topic is old, but you never know, by chance...

    The entire echo. (mentioned in one of the links) simulates the enter key well, but not the carriage return character.

    Example:
    echo.|pause
    => correctly shows a pause on which the system 'presses' the 'return' key by itself.

    The solution can't be far off...
    1
  3. gouli
     
    Suite à ton commentaire, j'ai modifié le script comme suit :
    Le script :
    for /f "delims=" %%a in ('type "%1"') do call :commande "%%a"
    goto :eof
    :commande

    set ligne=%1
    set ligne=%ligne:pi='\r\n'%
    set ligne=%ligne:"=%
    @echo %ligne% >> Nuevo/archivo.txt

    Le problème est qu'il ne reconnait pas et m'affiche donc \r\n au lieu du retour chariot.
    0
  4. gouli
     
    Same result, it shows me the characters \r\n.
    0
  5. gouli
     
    In fact, to tell you the truth, that's where I retrieved the script.
    But that damn carriage return character is impossible to find on the internet...
    0
  6. Non2 Posted messages 5103 Registration date   Status Contributor Last intervention   759
     
    Hello,

    The line break consists of two characters: carriage return (\r) and line feed (\n). This corresponds to characters 13 and 10 (0x0D and 0x0A).
    --
    If men were to speak only with knowledge, a deathly silence would fall upon the earth. (Anne O'Nym)
    -1
  7. Non2 Posted messages 5103 Registration date   Status Contributor Last intervention   759
     
    Have you tried "\r\n" instead of '\r\n'? It is a string of characters, not a single character.
    --
    If men could only speak with knowledge, a deathly silence would fall upon the earth. (Anne O'Nym)
    -1
  8. Non2 Posted messages 5103 Registration date   Status Contributor Last intervention   759
     
    I may have responded too quickly to your topic; it's been almost 10 years since I've touched a line of code, even in batch. But you can probably take inspiration from this: http://www.hotline-pc.org/batchscripts.htm#2501
    --
    If men were to speak only with knowledge of the matter, a deathly silence would fall upon the earth. (Anne O'Nym)
    -1
  9. Non2 Posted messages 5103 Registration date   Status Contributor Last intervention   759
     
    I think I found it:
    https://www.generation-nt.com/reponses/return-dans-un-script-batch-entraide-1967251.html
    But I don't know how to try it, as I'm not on Windows. A .txt file containing a carriage return, and we use the redirection: echo < crlf.txt.
    Strange nonetheless that it wouldn't be possible in batch. Otherwise, maybe try copy con. My memories are far away, but it would come back if I got to it.
    --
    If men were to speak only with knowledge of the facts, a deathly silence would fall upon the earth. (Anne O'Nym)
    -1