Add Line to txt batch

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
cumhur_28
Posts: 22
Joined: 22 Jul 2014 13:03

Add Line to txt batch

#1 Post by cumhur_28 » 22 Jul 2014 23:38

Hi Again;
thanx for your help for other question. it solved
i have another problem to solve.

i have txt file like
3453432432
6542312332
i need output file like that for each line

xxxxxxxx_01|3453432432
xxxxxxxx_02|6542312332

Please Help;

Regards.


CUMHUR

cumhur_28
Posts: 22
Joined: 22 Jul 2014 13:03

Re: Add Line to txt batch

#2 Post by cumhur_28 » 24 Jul 2014 08:39

is there any idea??

Aacini
Expert
Posts: 1926
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Add Line to txt batch

#3 Post by Aacini » 24 Jul 2014 09:27

Code: Select all

@echo off
setlocal EnableDelayedExpansion

set i=100
for /F "delims=" %%a in (theFile.txt) do (
   set /A i+=1
   echo xxxxxxxx_!i:~-2!^|%%a
)

cumhur_28
Posts: 22
Joined: 22 Jul 2014 13:03

Re: Add Line to txt batch

#4 Post by cumhur_28 » 04 Aug 2014 05:13

Aacini wrote:

Code: Select all

@echo off
setlocal EnableDelayedExpansion

set i=100
for /F "delims=" %%a in (theFile.txt) do (
   set /A i+=1
   echo xxxxxxxx_!i:~-2!^|%%a
)



thank you my friend.
when i use this bat it gives result in dos screen i need in txt file.
thanx for your help

regards

cumhur

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Add Line to txt batch

#5 Post by Squashman » 04 Aug 2014 07:25

cumhur_28 wrote:when i use this bat it gives result in dos screen i need in txt file.

Remember this part of code from your last batch file.

Code: Select all

>>"newfile.txt" echo %%a

http://www.robvanderwoude.com/redirection.php

cumhur_28
Posts: 22
Joined: 22 Jul 2014 13:03

Re: Add Line to txt batch

#6 Post by cumhur_28 » 04 Aug 2014 13:05

Squashman wrote:
cumhur_28 wrote:when i use this bat it gives result in dos screen i need in txt file.

Remember this part of code from your last batch file.

Code: Select all

>>"newfile.txt" echo %%a

http://www.robvanderwoude.com/redirection.php


thanx for your quick reply and sorry for my english when i added end of my batch file it gives %a.

and i doing something wrong

cumhur_28
Posts: 22
Joined: 22 Jul 2014 13:03

Re: Add Line to txt batch

#7 Post by cumhur_28 » 04 Aug 2014 13:09

@echo off
setlocal EnableDelayedExpansion

set i=100
for /F "delims=" %%a in (theFile.txt) do (
set /A i+=1
echo xxxxxxxx_!i:~-2!^|%%a
)
>>"newfile.txt" echo %%a

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Add Line to txt batch

#8 Post by Compo » 04 Aug 2014 13:37

cumhur_28 wrote:>>"newfile.txt" echo xxxxxxxx_!i:~-2!^|%%a

cumhur_28
Posts: 22
Joined: 22 Jul 2014 13:03

Re: Add Line to txt batch

#9 Post by cumhur_28 » 04 Aug 2014 14:17

thanx for your help finally you did it.
this forum is the best for batch's

thanx


cumhur

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Add Line to txt batch

#10 Post by Squashman » 04 Aug 2014 14:40

cumhur_28 wrote:@echo off
setlocal EnableDelayedExpansion

set i=100
for /F "delims=" %%a in (theFile.txt) do (
set /A i+=1
echo xxxxxxxx_!i:~-2!^|%%a
)
>>"newfile.txt" echo %%a

Image

cumhur_28
Posts: 22
Joined: 22 Jul 2014 13:03

Re: Add Line to txt batch

#11 Post by cumhur_28 » 05 Aug 2014 00:14

Squashman wrote:
cumhur_28 wrote:@echo off
setlocal EnableDelayedExpansion

set i=100
for /F "delims=" %%a in (theFile.txt) do (
set /A i+=1
echo xxxxxxxx_!i:~-2!^|%%a
)
>>"newfile.txt" echo %%a

Image


i promise this is my last question when i used this batch i will has two space end of the all lines.

how can i remove?

thanx

cumhur

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Add Line to txt batch

#12 Post by foxidrive » 05 Aug 2014 02:51

You have trailing or incorrect spaces in your batch file or in the text file.

cumhur_28
Posts: 22
Joined: 22 Jul 2014 13:03

Trim space characters problem

#13 Post by cumhur_28 » 06 Aug 2014 07:50

Hi;
i have txt files like.

Code: Select all

xxxxxxxx_01|54545454548488   
xxxxxxxx_02|89494984694964   



each end of the line has 2 space character and some program generates and i wont reach that to change it.

i want to remove this space character.

and i want to show this file in new txt file.

pls help

thanx
cumhur

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Trim space characters problem

#14 Post by Squashman » 06 Aug 2014 08:05

I am going to move this question to your previous thread because it looks to be related to your previous thread.

cumhur_28
Posts: 22
Joined: 22 Jul 2014 13:03

Re: Trim space characters problem

#15 Post by cumhur_28 » 06 Aug 2014 08:35

Squashman wrote:I am going to move this question to your previous thread because it looks to be related to your previous thread.



thank you my friend

Post Reply