Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

Re: Copy Files alongwith Folders

$
0
0

Just change the first line to choose the correct folders.

 

copyFolder(new Folder("C:/Source Folder"), new Folder("C:/Destination Folder"));  
function copyFolder(sourceFolder, destinationFolder) {    var sourceChildrenArr = sourceFolder.getFiles();    for (var i = 0; i < sourceChildrenArr.length; i++) {        var sourceChild = sourceChildrenArr[i];        var destinationChildStr = destinationFolder.fsName + "/" + sourceChild.name;        if (sourceChild instanceof File) {            copyFile(sourceChild, new File(destinationChildStr));        }        else{            copyFolder(sourceChild, new Folder(destinationChildStr));        }    }}  
function copyFile(sourceFile, destinationFile) {    createFolder(destinationFile.parent);    sourceFile.copy(destinationFile);}  
function createFolder(folder) {    if (folder.parent !== null&& !folder.parent.exists) {        createFolder(folder.parent);    }    folder.create();}

Viewing all articles
Browse latest Browse all 37788

Trending Articles