Ask a Question

Ony copy files and sub-folder in a folder to another

SOLVED
tuanvinh1008
Contributor

Ony copy files and sub-folder in a folder to another

Hi all,

I have the folders and files as structure

|Folder A

|   | Folder A1

|   |    | FileA1A.txt

|   |    | FileA1B.txt

|   | FileA.txt

|   | FileB.pdf

 

and I only want to copy all files and folders under the folderA to Folder B as structure below

 

|Folder B

|   | Folder A1

|   |    | FileA1A.txt

|   |    | FileA1B.txt

|   | FileA.txt

|   | FileB.pdf

 

If I use these code

var FolInfo = aqFileSystem.GetFolderInfo(FolderAPath);
// Copies the folder to another location
FolInfo.Copy(FolderB, false);

 

It will copy all files and folders include FolderA into FolderB as below. But I don't the copy the root folder name (Folder A)

FolderB

 |Folder A

 |   | Folder A1

 |    |    | FileA1A.txt

 |    |    | FileA1B.txt

 |    | FileA.txt

 |    | FileB.pdf

 

Thanks,

Vinh

1 ACCEPTED SOLUTION

Accepted Solutions
AlexKaras
Community Hero

Re: Ony copy files and sub-folder in a folder to another

Hi,

 

Consider WshShell.Run() and xcopy command (https://stackoverflow.com/questions/7170683/copy-all-files-and-folders-from-one-drive-to-another-dri...)

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

3 REPLIES 3
Marsha_R
Community Hero

Re: Ony copy files and sub-folder in a folder to another

Are you testing Windows?  Why do you need so many subfolders?

AlexKaras
Community Hero

Re: Ony copy files and sub-folder in a folder to another

Hi,

 

Consider WshShell.Run() and xcopy command (https://stackoverflow.com/questions/7170683/copy-all-files-and-folders-from-one-drive-to-another-dri...)

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

sonya_m
Community Manager

Re: Ony copy files and sub-folder in a folder to another

Thank you, Community!

 

@tuanvinh1008 did you try the suggested approach?


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: