Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Batch file Hope
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sam  
View profile  
 More options Oct 12 2011, 9:17 am
Newsgroups: microsoft.public.scripting.wsh
From: Sam <samcan...@gmail.com>
Date: Wed, 12 Oct 2011 06:17:46 -0700 (PDT)
Local: Wed, Oct 12 2011 9:17 am
Subject: Batch file Hope
I have this batch below that combines file with a header in each
file.  This combines the files and removes the header.  What I need is
to combine the files but take the header row from one of the files and
put it in the file that has all the files combined.

Thanks in advance for your help!!!!

DEL FileList_Combined_ELI.csv
DEL Combined_ELI.csv
dir *.csv/b > filelist
for %%a in (*.csv) do more +1 %%a > CombinedELI
Rename "CombinedELI" "Combined_ELI.csv"
Rename "filelist" "FileList_Combined_ELI.csv"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Lavedas  
View profile  
 More options Oct 12 2011, 11:50 am
Newsgroups: microsoft.public.scripting.wsh, alt.msdos.batch.nt
From: Tom Lavedas <tglba...@verizon.net>
Date: Wed, 12 Oct 2011 08:50:38 -0700 (PDT)
Local: Wed, Oct 12 2011 11:50 am
Subject: Re: Batch file Hope
On Oct 12, 9:17 am, Sam <samcan...@gmail.com> wrote:

> I have this batch below that combines file with a header in each
> file.  This combines the files and removes the header.  What I need is
> to combine the files but take the header row from one of the files and
> put it in the file that has all the files combined.

> Thanks in advance for your help!!!!

> DEL FileList_Combined_ELI.csv
> DEL Combined_ELI.csv
> dir *.csv/b > filelist
> for %%a in (*.csv) do more +1 %%a > CombinedELI
> Rename "CombinedELI" "Combined_ELI.csv"
> Rename "filelist" "FileList_Combined_ELI.csv"

The microsoft.public.scripting.wsh group is not the right place for
this question.  First, microsoft has 'adandoned' it and second, it is
intended for questions related to Windows Script Host (WSH).  Batch is
not WSH.  Therefore, I have redirected my response into
alt.msdos.batch.nt, which is a more appropriate place for this
discussion.

However, to answer your question, maybe something like this will
serve ...

DEL FileList_Combined_ELI.csv 2> nul
DEL Combined_ELI.csv 2> nul
dir *.csv/b > filelist
set /p First= < filelist
copy %First% CombinedELI > nul
for %%a in (*.csv) do if /i not %%a==%First% more +1 %%a >>
CombinedELI
Rename "CombinedELI" "Combined_ELI.csv"
Rename "filelist" "FileList_Combined_ELI.csv"

It copies the first file in the list in total (including its header)
to the combined destination and then adds all the rest, minus their
first lines.
___________________________________
Tom Lavedas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »