Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

combine multiple text files in one

- - - - -

  • Please log in to reply
10 replies to this topic

#1
colore

colore

    Advanced Member

  • Member
  • PipPipPip
  • 493 posts
hello

I need to combine multiple text files in one

I mean to stitch them one after the other

is there a program that can do this?

I used TXT Collector and Text Magician but none did it (there are 100,000 txt files)

thanks


How to remove advertisement from MSFN

#2
Glenn9999

Glenn9999

    Senior Member

  • Member
  • PipPipPipPip
  • 668 posts
  • OS:Windows 8 x64
  • Country: Country Flag
you should be able to use the straight copy command, I would think.

copy *.txt mytextfile.txt

Or some such thing. You would have to load the result file up and make formatting changes, etc, but hopefully it should work out for you.

#3
colore

colore

    Advanced Member

  • Member
  • PipPipPip
  • 493 posts

copy *.txt mytextfile.txt


thanks! this works!

EDIT:

mmm there is a problem

the files are sorted per filename in the explorer and this is the sequence in which I want to combine them:

1.txt
10.txt
20.txt
etc

but the above command combines them in this order:

1.txt
10.txt
100.txt
etc

any idea?

Edited by colore, 03 March 2008 - 05:43 PM.


#4
aadipa

aadipa

    Newbie

  • Member
  • 45 posts
may be you can try this.. little longer but it will work for you.

copy ?.txt 01.tmp
copy ??.txt 02.tmp
copy ???.txt 03.tmp
...

like this... this will get all 0.txt - 9.txt in 01.tmp, then 10.txt-99.txt in 02.tmp and so on. once you are done this, then get all tmp files merged.
copy *.tmp final.txt

A bit lengthy, but it will do the job.

#5
colore

colore

    Advanced Member

  • Member
  • PipPipPip
  • 493 posts
unfortunately it doesn't the job

for example this:
copy ??.txt 02.tmp

combines these:
1.txt
10.txt
100.txt
110.txt
120.txt
130.txt
140.txt
150.txt
160.txt
170.txt
180.txt
190.txt
20.txt
200.txt
210.txt
220.txt
230.txt
240.txt
250.txt
260.txt
270.txt
280.txt
290.txt
30.txt
300.txt
310.txt
320.txt
330.txt
340.txt
350.txt
360.txt
370.txt
380.txt
390.txt
40.txt
400.txt
410.txt
420.txt
430.txt
440.txt
450.txt
460.txt
470.txt
480.txt
490.txt
50.txt
500.txt
510.txt
520.txt
530.txt
540.txt
550.txt
560.txt
570.txt
580.txt
590.txt
60.txt
600.txt
610.txt
620.txt
630.txt
640.txt
650.txt
660.txt
670.txt
680.txt
690.txt
70.txt
700.txt
710.txt
720.txt
730.txt
740.txt
750.txt
760.txt
770.txt
780.txt
790.txt
80.txt
800.txt
810.txt
820.txt
830.txt
840.txt
850.txt
860.txt
870.txt
880.txt
890.txt
90.txt
900.txt
910.txt
920.txt
930.txt
940.txt
950.txt
960.txt
970.txt
980.txt
990.txt

#6
colore

colore

    Advanced Member

  • Member
  • PipPipPip
  • 493 posts
what I suppose would do the job is to put zeros in front of the filenames

but is there any program that will put zeros in front of the filenames, but make all the filenames have the same number of digits?

I mean, it must not just add 3 zeros in front of all filenames, it should add
3 zeros infront of ?.txt filenames
2 zeros in front of ??.txt filenames
1 zero in front of ???.txt filenames
etc

example:

I have:
2150
61250478
122

and need:

00002150
61250478
00000122

Edited by colore, 04 March 2008 - 08:22 AM.


#7
IcemanND

IcemanND

    MSFN Junkie

  • Super Moderator
  • 3,266 posts
  • OS:Windows 7 x64
  • Country: Country Flag
how's this, will pad the file name with zero's in front to end up with an 8 character filename.
@echo off
setlocal enableextensions
setlocal enabledelayedexpansion

for %%? in (*.txt) do (
	set fname=%%?
	set fname=!fname:~0,-4!
	set nname=
	for /l %%z in (7,-1,0) do (
		if "!fname:~%%z!"=="" (
			set nname=0!nname!
		)
	)
	ren "%%?" "!nname!%%?"
)


#8
aadipa

aadipa

    Newbie

  • Member
  • 45 posts

unfortunately it doesn't the job

for example this:
copy ??.txt 02.tmp

combines these:
1.txt
10.txt
100.txt
...

i don't think ??.txt will match with 100.txt
? represents 0 or 1 charactor. so it will be max 2 digit file name, not 3 digit.

but in your case, ??.txt will match both 1.txt and 10.txt.
may be you can move files which you have merged to some other folder using move command.
copy ?.txt 01.tmp
md 1
move ?.txt 1

copy ??.txt 02.tmp
md 2
move ?.txt 2

copy ???.txt 03.tmp
md 3
move ?.txt 3


#9
colore

colore

    Advanced Member

  • Member
  • PipPipPip
  • 493 posts

how's this, will pad the file name with zero's in front to end up with an 8 character filename.

@echo off
setlocal enableextensions
setlocal enabledelayedexpansion

for %%? in (*.txt) do (
	set fname=%%?
	set fname=!fname:~0,-4!
	set nname=
	for /l %%z in (7,-1,0) do (
		if "!fname:~%%z!"=="" (
			set nname=0!nname!
		)
	)
	ren "%%?" "!nname!%%?"
)


thanks
but how do I use this?

aadipa, indeed, I wanted to write ???.txt, sorry

#10
IcemanND

IcemanND

    MSFN Junkie

  • Super Moderator
  • 3,266 posts
  • OS:Windows 7 x64
  • Country: Country Flag
save it as pad_zeros.cmd in the folder with your files. the double click

#11
Grake

Grake

    Advanced Member

  • Member
  • PipPipPip
  • 369 posts
Use Vim




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN