Thursday, October 18, 2007

Tips to copy preserving dir structure

I had this weird requirement. I had to copy a set of different files from different directories from a source folder to a target folder and preserve the directory structure. For instance

Source File: c:\temp\test\abc.txt
Target Folder: e:\test

Copy the Source File into the Target folder preserving the dir structure. I need to achieve the following after copying
e:\test\temp\test\abc.txt

The best solution is to create a jar/zip file and keep on appending it with the file entries. Then copy the jar/zip file to target folder and extract the files. This will keep the directories preserved.

2 comments:

Hari said...

If you are in windows environment use

xcopy /e /s

Rajakumar said...

Will try that next time