Is it possible to copy all files under a specific relative path?
For example: Copy all files under
‘..preSetting’ + ‘/bb/’to
Folder.desktop + ‘/aa/’My path structure is as follows, with “Script” at the same level as preSetting:
D:/OO/Script/myscript.jsx
D:/OO/preSetting/bb/
This one below seems wrong.
//var activeDocPath = String(app.activeDocument.fullName);
var copyToPath = String(Folder.desktop + '/aa/');
var sPath = String("/" + PreSetting + '/bb/');
//alert(sourcePath);
//alert(pShortcut);
var copiedFile = copyFile(sPath, copyToPath);
function copyFile(sourcePath, destinationPath) {
var fp = Folder(sourcePath)
//get the files in MyFiles
var f = fp.getFiles();
alert(f);
alert(f.length);
for (var i = 0; i < f.length; i++) {
//try {
if (!f[i].exists) {
throw new Error('File not found: "' + sourcePath + '".');
}
else {
var dup = File(destinationPath);
f[i].copy(dup)
return dup;
}
}
}
