Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

concatenate text files including the name

21 views
Skip to first unread message

Ammammata

unread,
Apr 25, 2017, 4:36:47 AM4/25/17
to
hi there

I have several txt files I'd like to put together but with their name
included before the actual txt

i.e. (final output)

1.txt

1111111

2.txt

222222

3.txt

333333


and so on


copy hasn't such option, neither xcopy

TIA

--
/-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\
-=- -=- -=- -=- -=- -=- -=- -=- - -=-
>>>>> http://www.bb2002.it :) <<<<<
........... [ al lavoro ] ...........

Ammammata

unread,
Apr 25, 2017, 4:39:54 AM4/25/17
to
Il giorno Tue 25 Apr 2017 10:36:45a, *Ammammata* ha inviato su
alt.msdos.batch.nt il messaggio
news:XnsA7626BFBCEB43am...@148.251.67.112. Vediamo cosa ha
scritto:

> I have several txt files I'd like to put together but with their name
> included before the actual txt
>

@echo off
for /r %%i in (*.txt) do (
if not %%~nxi == output.txt (
echo %%~nxi >> output.txt
type "%%i" >> output.txt
echo. >> output.txt
echo =================================================================== >>
output.txt
)
)
Address : <http://www.tomshardware.co.uk/answers/id-2612574/merge-txt-
files-include-filenames-txtcollector-quit-working.html>

npocmaka

unread,
May 3, 2017, 10:45:39 AM5/3/17
to
the fastest way:

type *.txt >result.file

npocmaka

unread,
May 3, 2017, 11:08:34 AM5/3/17
to
file names are printed in the error stream so you'll actually need:

type *.txt >result.file 2>&1
0 new messages