copy multiple file in a folder to a specific text file but add carriage return for each file copied using a bat command

I am looking to copy multiple file to a single file but want to separate each file with a new line

I am using type \inbox\*.* >> received.txt

It copies the file but into one long line, I need to separate each file copied to be in a new line.
tvaeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITCommented:
At the CMD prompt...
for %a in (\inbox\*.*) do (type "%a" >> received.txt)

Open in new window


To run it in a .bat file, change each % to %%. i.e....
for %%a in (\inbox\*.*) do (type "%%a" >> received.txt)

Open in new window

0
Steven CarnahanNetwork ManagerCommented:
To take NVIT's batch file one step further to accomplish the blank line try:

for %%a in (\inbox\*.*) do (
type "%%a" >> received.txt
echo. >> received.txt
)

Open in new window

0
tvaeAuthor Commented:
This didn't add a carriage return or a blank line :( it just copied the files
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

NVITCommented:
A variation of Pony's... To make the giant file easier to read, add the filename with dashes above the file's text:
for %%a in (\inbox\*.*) do (
  echo "%%a" ---------------------------------------------->> received.txt
  type "%%a" >> received.txt
)

Open in new window

0
tvaeAuthor Commented:
NVIT,
that didn't work. I need every file to be a new line cause I have to read this file and the beginning of each file is critical in my query
0
NVITCommented:
> that didn't work.
What are you getting?

What should it look like?

My samples return something like this:

"file1.txt" ----------------------------------------------
text
text
"file2.txt" ----------------------------------------------
text
text

Open in new window

0
tvaeAuthor Commented:
I am getting
file1datafile2data its concatenated
0
NVITCommented:
Is everything in each of your files on 1 line?
Can you give a sample of the actual file?
0
tvaeAuthor Commented:
Here's a sample
IN201305061600135823032.txt
0
NVITCommented:
for %%a in (\inbox\*.*) do (
  echo.>> received.txt
  echo "%%a" ---------------------------------------------->> received.txt
  type "%%a" >> received.txt
)

Open in new window

0
Bill PrewCommented:
Give this a try, should get the job done.  Adjust paths in the SET statements near the top.

@echo off

set BaseDir=B:\EE\EE28807419\inbox
set OutFile=B:\EE\EE28807419\received.txt

(
  for %%a in ("%BaseDir%\*.*") do (
    type "%%~a"
    echo.
    echo.
  )
)>"%OutFile%"

Open in new window

~bp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tvaeAuthor Commented:
ok sorry to be a pain but I just have this in my bat and it does not work. am I missing anything

for %%a in (\inbox\receive\*.*)  do (type "%%a" >> Received.txt)
0
tvaeAuthor Commented:
Bill Prew

That worked brilliantly
Thanks
0
NVITCommented:
Mine works, too. 8-P
0
Bill PrewCommented:
Welcome.

~bp
0
Steven CarnahanNetwork ManagerCommented:
Bill,

Both NVIT and I tested ours several times and they worked.  Can you see what we were doing incorrect?  I like your solution however I wonder why you put to "echo." lines in.  Wouldn't that cause 2 blank lines?

Even at 60 I'm not too old to learn.  :)
0
Bill PrewCommented:
It's about the actual data files, they don't have a line feed at the end of the line which makes a difference.

~bp
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.