How can I copy an entire folder that contains multiple layers of subfolders?When I need to copy an entire folder, I can use the `copy file()` function for step-by-step copying each file in this folder. Using `Files In Directory()` to obtain the names of all files in the folder, and for looping copying files.
However, if the folder I need to copy contains subfolders, using `copy file` will result in errors. In fact, if there are multiple layers of subfolders within the folder that I need to copy, it becomes difficult for me to write JSL.
Are there any good suggestions for solving the issue of copying folders that contain multiple layers of subfolders?
Automation and ScriptingRe: How can I copy an entire folder that contains multiple layers of subfolders?You have not described the issue in sufficient detail to allow for a solution.
What errors are you getting when dealing with subfolders? Are you attempting to copy the subfolder file to the same subfolder on a different drive or are all files going to end up on a single folder?
Re: How can I copy an entire folder that contains multiple layers of subfolders?Have you looked at Copy Directory()?

Re: How can I copy an entire folder that contains multiple layers of subfolders?// Create Sample Flie in Document folder (a folder with one text file and a sub folder which also have a text file)
baseDir = "$DOCUMENTS";
dir = baseDir || "/" || Substitute( MDYHMS( Today() ), "/", "-", ":", "." );
Create Directory( dir );
theText = "Copy Test";
Save Text File( dir || "/0_Test Copy1.txt", theText );
dir2 = dir || "/" || Substitute( MDYHMS( Today() ), "/", "-", ":", "." );
Create Directory( dir2 );
Save Text File( dir2 || "/Test Copy2.txt", theText );
//Copy Sample Files
Wait( 1 );
CopyFilesList = Files In Directory( dir );
CopyPath= baseDir || "/" || Substitute( MDYHMS( Today() ), "/", "-", ":", "." );
//The error message appears when the copy target is a folder.
For( Count = 1, Count <= N Items( CopyFilesList ), Count++,
Copy File( dir || "/" || CopyFilesList[Count], CopyPath || "/" || CopyFilesList[Count] )
);
The error message occurs after running the example above. An error message appears when the copy target is a folder.