Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying only one level subdirectories of one directory to Another

Status
Not open for further replies.

techi1

Technical User
Sep 13, 2006
1
US
Hi,
I have a problem regarding that how to copy the first level subdirectoris of one directory to another. I have tried but found only code that copies the entire contents of the directory. Could anyone please help it out.
Thank you.
 
I'm a bit confused about what you're trying to do.
Lets say you have the following directory structure (let D be a directory and F be a file):

Code:
Droot
 |--->D1
 |    |--->Dsub1
 |    |     |--->F1
 |    |     |--->DsubSub1
 |    |
 |    |--->Dsub2
 |    |     |--->F2
 |    |
 |    |--->F3
 |
 |--->D2
Are you saying that you want to copy only Dsub1 & Dsub2 (including everything below them) from D1 to D2, but not copy F3?
 
I think he wants to copy F3 and "stubs" or empty directories for Dsub1 and Dsub2.

Pseudo code: (If necessary I'll copy the code from the other machine)
Code:
filefound = FindFirst( d1 );
do
{
   if ( isdir( filefound ) )
      mkdir( d2 + filename( filefound ) ) ;
   else
      copyfile( d1 + filename( filefound ), d2 + filename( filefound ) ) ;
} while filefound = FindNext() ;
EndFind() ;

Double check the library help for FindFirst and FindNext for parameters and return values. I'm also not sure if it's EndFind or FindClose.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top