Computing.Net > Forums > Disk Operating System > Copy files only out of sub folders

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Copy files only out of sub folders

Reply to Message Icon

Name: bri17
Date: April 23, 2004 at 18:42:29 Pacific
OS: XP Home
CPU/Ram: p4/512
Comment:

Hi. I have a deep directory tree. for example:
c:\0001
c:\0002
c:\0003
c:\0004

Does anyone know how I can copy all of the files that start with T?

I've tried xcopy t*.* c:\test\*.* /s but this copies the folders\subfolders as well. I just want to end up with all of the files in one folder. Anyone have any ides?

I have way to many folders\subfolders to write a batch file going to each folder



Sponsored Link
Ads by Google

Response Number 1
Name: Wengier
Date: April 25, 2004 at 21:30:16 Pacific
Reply:

You'd better post this question in Programming Forum or Windows XP Forum, as the warning messages of this forum state.

---------------
Long Live DOS!


0

Response Number 2
Name: sillygates
Date: April 27, 2004 at 20:09:21 Pacific
Reply:

Don't go in circles on computing.net when you could simply download cp.exe (the linux version of copy, that can do that task very simply). I'm not exactly sure where you can download that file directly, but it is part of the "Cygwin" linux toolkit released by redhat, try surfing through their ftp servers for it (it will be located in the path /bin/ directory under cygwin), or hell, just download the whole toolkit at http://www.cygwin.com/(it has a lot of great tools never seen on windows including ssh, etc)

Good luck
josh


0

Response Number 3
Name: Mechanix2Go
Date: May 30, 2004 at 07:04:16 Pacific
Reply:

Hi,

You said:

"Hi. I have a deep directory tree. for example:
c:\0001
c:\0002
c:\0003
c:\0004

Does anyone know how I can copy all of the files that start

with T?"

Looks like your tree is WIDE, not DEEP.

In the case you show, run the BAT from C:\

But if it's DEEP and WIDE go to the directory immediately

above the folders of interest. Like this:

c:\a\b\x\z\w\0001
c:\a\b\x\z\w\0002
c:\a\b\x\z\w\0003
c:\a\b\x\z\w\0004

If your tree looks like what's above,

cd c:\a\b\x\z\w

and run it from there. It copies only files in the

directories immediately below named T*.* and NOT lower

folders.

The /D at the END of the working line tells xcopy to copy only

newer files. If you want to copy all, regardless of date, and

don't want to be prompted for every overwrite, replace /D with

/F or if you want to be preompted, don't use either /D or /F.

You need to tell it where to put the files, like this:

MyNew.BAT e:\allTfiles\

Include the final \ and [1] it will create the folder if needed and [2] it won't ask you if the destination is a drive or directory.

Let me know if it's what you need.

******************************

@echo off > quit.bat
@echo echo %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 >> quit.bat

echo.
echo This is the world famous %0.bat
echo.
echo copyright 2004 ThaiGuides.com All rights reserved
echo.
echo Free for private use. Others email: Consult@ThaiGuides.com
echo.
echo built and tested on windoze 2000; may act funny on other versions
echo.
echo.
echo. The purpose is to copy files from many folders below the current one
echo. to a single location
echo.
echo. 20:12 30 May 2004
echo.
echo.
echo.

if %1'==' quit where are the files going?

for /D %%F in (*) do xcopy %%F\T*.* %1 /D

echo.
echo Thank you for playing


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Copy files only out of sub folders

Dir list of files only,no subfolder www.computing.net/answers/dos/dir-list-of-files-onlyno-subfolder/15578.html

copy files from internet under DOS www.computing.net/answers/dos/copy-files-from-internet-under-dos/12300.html

how to copy files using date www.computing.net/answers/dos/how-to-copy-files-using-date/12582.html