PC Review


Reply
Thread Tools Rate Thread

Copying files from command prompt

 
 
=?Utf-8?B?TWF0dGhld1I=?=
Guest
Posts: n/a
 
      6th Feb 2007
I am having trouble figuring out how to copy multiple files from multiple
directories into a single file.

I have a file structure like this:

C:
\20060101
\20060102
\20060103
...

Each directory has several files named like this: 1.txt, 2.txt, 3.txt, ...

What I want to do is copy each 3.txt file from each subdirectory into a
single file. Basically, I want something that works like this (this command
doesn't work):

copy c:\*\3.txt c:\appendedfile.txt

I've tried variations of both copy and xcopy with no luck. Hoping someone
here has an idea. I'd even take a solution that you can do from the Window
XP UI (using Search or something like that).


 
Reply With Quote
 
 
 
 
Ayush
Guest
Posts: n/a
 
      6th Feb 2007
Replied to [MatthewR]s message :
> I am having trouble figuring out how to copy multiple files from multiple
> directories into a single file.
>
> I have a file structure like this:
>
> C:
> \20060101
> \20060102
> \20060103
> ...
>
> Each directory has several files named like this: 1.txt, 2.txt, 3.txt, ...
>
> What I want to do is copy each 3.txt file from each subdirectory into a
> single file. Basically, I want something that works like this (this command
> doesn't work):
>
> copy c:\*\3.txt c:\appendedfile.txt
>
> I've tried variations of both copy and xcopy with no luck. Hoping someone
> here has an idea. I'd even take a solution that you can do from the Window
> XP UI (using Search or something like that).
>
>



I think VBs or JS will be a better solution for this (post in vbs, js or wsh group).


Good Luck, Ayush.
--
XP-Tips [Speed up menu display] :
http://www.microsoft.com/windowsxp/u...tips/menu.mspx
 
Reply With Quote
 
cornedbeef007-groups@yahoo.com.au
Guest
Posts: n/a
 
      6th Feb 2007
On Feb 7, 6:29 am, MatthewR <Matth...@discussions.microsoft.com>
wrote:
> I am having trouble figuring out how to copy multiple files from multiple
> directories into a single file.
>
> I have a file structure like this:
>
> C:
> \20060101
> \20060102
> \20060103
> ...
>
> Each directory has several files named like this: 1.txt, 2.txt, 3.txt, ...
>
> What I want to do is copy each 3.txt file from each subdirectory into a
> single file. Basically, I want something that works like this (this command
> doesn't work):
>
> copy c:\*\3.txt c:\appendedfile.txt
>
> I've tried variations of both copy and xcopy with no luck. Hoping someone
> here has an idea. I'd even take a solution that you can do from the Window
> XP UI (using Search or something like that).


use copy /? to see the options for copy command.

You can specify multiple source files in a copy like this

copy source1.txt + source2.txt + source3.txt destination.txt

you can include the path in the source file

copy c:\dir1\1.txt + c:\dir2\1.txt + c:\dir3\1.txt c:
\appendedfile.txt

You can use absolute path as above, or relative path.

Go for it!

Good Luck,
Barry.

 
Reply With Quote
 
3c273
Guest
Posts: n/a
 
      6th Feb 2007
I just tried your example and it works fine here. If it is not working for
you, you could download the GNU Utilities (Open Source/Freeware) which
contains a win32 port of the unix "cat" command which does what you want.
Louis

"MatthewR" <(E-Mail Removed)> wrote in message
news:E15DC5B7-DC99-4E46-AD8D-(E-Mail Removed)...
> I am having trouble figuring out how to copy multiple files from multiple
> directories into a single file.
>
> I have a file structure like this:
>
> C:
> \20060101
> \20060102
> \20060103
> ...
>
> Each directory has several files named like this: 1.txt, 2.txt, 3.txt, ...
>
> What I want to do is copy each 3.txt file from each subdirectory into a
> single file. Basically, I want something that works like this (this

command
> doesn't work):
>
> copy c:\*\3.txt c:\appendedfile.txt
>
> I've tried variations of both copy and xcopy with no luck. Hoping someone
> here has an idea. I'd even take a solution that you can do from the

Window
> XP UI (using Search or something like that).
>
>



 
Reply With Quote
 
=?Utf-8?B?TWF0dGhld1I=?=
Guest
Posts: n/a
 
      6th Feb 2007
The problem is that there are hundreds of subdirectories which I'd have to
concatenate one at a time.

"cornedbeef007-(E-Mail Removed)" wrote:

> On Feb 7, 6:29 am, MatthewR <Matth...@discussions.microsoft.com>
> wrote:
> > I am having trouble figuring out how to copy multiple files from multiple
> > directories into a single file.
> >
> > I have a file structure like this:
> >
> > C:
> > \20060101
> > \20060102
> > \20060103
> > ...
> >
> > Each directory has several files named like this: 1.txt, 2.txt, 3.txt, ...
> >
> > What I want to do is copy each 3.txt file from each subdirectory into a
> > single file. Basically, I want something that works like this (this command
> > doesn't work):
> >
> > copy c:\*\3.txt c:\appendedfile.txt
> >
> > I've tried variations of both copy and xcopy with no luck. Hoping someone
> > here has an idea. I'd even take a solution that you can do from the Window
> > XP UI (using Search or something like that).

>
> use copy /? to see the options for copy command.
>
> You can specify multiple source files in a copy like this
>
> copy source1.txt + source2.txt + source3.txt destination.txt
>
> you can include the path in the source file
>
> copy c:\dir1\1.txt + c:\dir2\1.txt + c:\dir3\1.txt c:
> \appendedfile.txt
>
> You can use absolute path as above, or relative path.
>
> Go for it!
>
> Good Luck,
> Barry.
>
>

 
Reply With Quote
 
Ayush
Guest
Posts: n/a
 
      6th Feb 2007
Replied to [MatthewR]s message :
> The problem is that there are hundreds of subdirectories which I'd have to
> concatenate one at a time.



OK, if you dont want to use VBS then :
Open the folder with multiple subfolders in explorer
Click Search at top
Enter 3.txt in Find box and after search is done, copy all the files in one directory.
Make a bat file :

type C:\TheDirectoryWith3.TxFiles\*.* > SomeFile


Run it


And you can list the 3.txt files without searching by using this command:
Go into the directory and run :

dir /s /a-d /b "3.txt"

or from anywhere :
dir /s /a-d /b "Folder\3.txt"

but i dont know how to send it to copy or type command.It is possible by sending the
dir result to text file then reading the text file line/by/line and run the command
but i dont know how..


Good Luck, Ayush.
--
XP-Tips [Change the default folder opened in Explorer] :
http://www.microsoft.com/windowsxp/u...ingfolder.mspx
 
Reply With Quote
 
=?Utf-8?B?TWF0dGhld1I=?=
Guest
Posts: n/a
 
      7th Feb 2007
Thanks for the tip on the GNU utilities. I don't think I'll end up using
them here but I'll likely find use for them in the future. (Why can't
Microsoft put this kind of useful functionality in their command line tools?)

I've decided to simply rename the files in each directory so that they use
the directory name in the extention. "3.txt" in the "\20060101" directory
becomes "3.txt_20060101". That way I can just use the Windows Search
funcationality to find all "3.*" files and copy them to a new folder and use
the copy command to concatenate them all.


"3c273" wrote:

> I just tried your example and it works fine here. If it is not working for
> you, you could download the GNU Utilities (Open Source/Freeware) which
> contains a win32 port of the unix "cat" command which does what you want.
> Louis
>
> "MatthewR" <(E-Mail Removed)> wrote in message
> news:E15DC5B7-DC99-4E46-AD8D-(E-Mail Removed)...
> > I am having trouble figuring out how to copy multiple files from multiple
> > directories into a single file.
> >
> > I have a file structure like this:
> >
> > C:
> > \20060101
> > \20060102
> > \20060103
> > ...
> >
> > Each directory has several files named like this: 1.txt, 2.txt, 3.txt, ...
> >
> > What I want to do is copy each 3.txt file from each subdirectory into a
> > single file. Basically, I want something that works like this (this

> command
> > doesn't work):
> >
> > copy c:\*\3.txt c:\appendedfile.txt
> >
> > I've tried variations of both copy and xcopy with no luck. Hoping someone
> > here has an idea. I'd even take a solution that you can do from the

> Window
> > XP UI (using Search or something like that).
> >
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
find files with command prompt madjac Security and Anti-Spyware Community 4 3rd Jan 2008 08:58 PM
DOS .... Command Prompt ..... Batch Files Microsoft Windows 2000 CMD Promt 2 26th Jun 2005 05:23 PM
renaming/copying files at dos prompt? =?Utf-8?B?RGFsZQ==?= Microsoft Windows 2000 3 23rd Dec 2004 11:31 PM
Compress files via command prompt M. Noroozi Eghbali Windows XP General 2 13th Dec 2004 06:48 PM
delete files in command prompt Matt Microsoft Windows 2000 3 31st Oct 2004 06:27 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:23 AM.