# script to print text without new line character



## Codesearcher (May 13, 2009)

Hi i have a requirement to re-direct the list of DOS commands into a text file with a blank space inbetween them
eg:
echo "Y:\Drive\tar" > test.txt
echo "-cf test.tar" >> test.txt
echo "*.xml" >> test.txt

so i need to print Y:\Drive\tar -cf test.tar *.xml in test.txt 

Instead its getting printed as 
Y:\Drive\tar
-cf test.tar
*.xml

after printing the command pass the line as an input to the command prompt and i should execute that line.

Kindly help me in doing this.


----------



## TheOutcaste (Mar 19, 2009)

You can't. Echo will output a CR/LF after each line.
The quotes will be echoed, so don't include them unless they are really needed, like around a file name.
Just Echo the three parts all on one line:

```
>test.txt Echo "Y:\Drive\tar" -cf test.tar *.xml
Copy test.txt test.bat
Call test.bat
Del Test.bat
```
Or set it as a variable:

```
Set _CmdLine="Y:\Drive\tar" -cf test.tar *.xml
>test.txt Echo.%_CmdLine%
%_CmdLine%
```
Or after echoing each part, read the file in, combine the lines, and output it back to the file:

```
>test.txt Echo "Y:\Drive\tar"
>>test.txt Echo -cf test.tar
>>test.txt Echo *.xml
SetLocal EnableDelayedExpansion
Set _CmdLine=
For /F "Tokens=1 Delims=" %%I In ('Type Test.txt') Do Set _CmdLine=!_CmdLine! %%I
Set _CmdLine=%_CmdLine:~1%
>test.txt Echo %_CmdLine%
%_CmdLine%
```


----------



## Codesearcher (May 13, 2009)

Hey thank you so much! its working great!!!
I need one more help too....
I have few lines in my test.txt file (which was echo from the DOS command) like

Y:\Drive\tar
DW_Bank*.xml
DW_Bank.tar
DW_Day*.xml
DW_Day.tar
DW_Daily.xml
DW_Daily.tar

I want this to be 
Y:\Drive\tar DW_Bank*.xml DW_Bank.tar
Y:\Drive\tar DW_Day*.xml DW_Day.tar
Y:\Drive\tar DW_Daily*.xml DW_Daily.tar

Is this possible?
Need your help in this regard!!


----------



## TheOutcaste (Mar 19, 2009)

Unless there is a fixed pattern to these lines, it would be nearly impossible to write a script. and unless there are hundreds of lines, probably faster to just edit by hand, using Notepad++ or Notetab Light, where you can search for lines containing only *Y:\Drive\tar*, then easily combine them with a few clicks/key presses.

Is it always *Y:\Drive\tar* followed by 3 pairs of lines you need to combine as you show?
Or is it actually like this:
Y:\Drive\tar
DW_Bank*.xml
DW_Bank.tar
Y:\Drive\tar
DW_Day*.xml
DW_Day.tar
Y:\Drive\tar
DW_Daily.xml
DW_Daily.tar

Does there happen to be a space (or multiple spaces) after *Y:\Drive\tar*?
If some have none, some have one, some have more, you have to allow for that. If none of the file names or paths have spaces, it would be easier, but if any have spaces that gets complicated real quick.


----------

