Copy link to clipboard
Copied
Hi Forum!
I have this bit of script to copy files which resides inside the Folder.
My request to forum, is to get help, to copy all the contents inside the folder...
contents inside the folder, can be *.indd, *.zip, *.tif, *.eps etc., and also the folders inside the folders and its contents..
Currently I can only able to copy only the files (*.*) inside the folder and cant able to copy the folder inside the folder and its files...
var copyFolder1 = Folder('/Users/admin/Desktop/LZW/For General');
var pasteFolder1 = Folder('/Volumes/CTC/Normal/MyFiles');
var myFiles2 = copyFolder1.getFiles( '*.*');
for ( i = myFiles2.length-1; i >= 0 ; i-- ){
var myResult = myFiles2.copy(pasteFolder1 +"/" + myFiles2.name);
}
Please can I get help to do this.
thanks & rgs.
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;
var destinationChildStr = destinationFolder.fsName + "/" + sourceChild.name;
if (sourceChild instanceof File) {
copyFile(sourceChil
Copy link to clipboard
Copied
Well, I have this too.
But the problem is I can't able to do copy..
var myObject = new ActiveXObject("Scripting.FileSystemObject");
var myFolder = myObject.GetFolder("/Users/admin/Desktop/LZW/For General");
myFolder.Copy("/Volumes/CTC/Normal/MyFiles", true);
Result while runnig script is :ActiveXObject does not have a constructor.
Please help!... and advance thanks to forum...
Copy link to clipboard
Copied
HI Forum,
Does my request make sense! Please forgive me if not.
Because I'm not interestingly trying with the actual java code and not even i'm familiar with too.
Will be much appreciated, to get it help on any other way to copy the entire folder and its contents.
thanks in advance..
Copy link to clipboard
Copied
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;
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();
}
Copy link to clipboard
Copied
Really helpfull dln385,
Thanks so much for your inpurt to meet my request.
I shall be checking withing an hour and let you know if any doubt arouses.
thanks you so much..
Copy link to clipboard
Copied
Copy link to clipboard
Copied
ExtendScript is mostly JavaScript. First learn JavaScript.
Then learn ExtendScript.
Copy link to clipboard
Copied
In addition to the full answer you could take a note that "ActiveXObject" is not supported by the ExtendScript javascript used by InDesign. Instead a separate set of File handling objects/methods is implemented, that works for MacOS and Windows. ActiveXObject is probably windows specific.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now