Hi all!
Is there some way to copy files and folders? My script has to copy files of various types and the only way I know is to create temporary .bat files with xcopy bla-bla, execute them and delete.
Standart method File(path).copy(target) doesn't work in my script, I don't know why...
Thanks.
How to copy a file or a folder ? :)
Moderator: Paul Tuersley
I've got a solution!
My friend have written for me a function of copying folders
If it is interesting for anybody, here it is:
function my_copy_dir(dest)
{
var dest_obj = new Folder(dest);
if(!dest_obj.exists)
{
dest_obj.create();
}
var files = this.getFiles();
for(var i = 0;i<files.length;i++)
{
files.copy2(dest_obj.absoluteURI+'/'+files.name);
}
}
function my_copy_file(dest)
{
  this.copy(dest);
}
Folder.prototype.copy2 = my_copy_dir;
File.prototype.copy2 = my_copy_file;
dirFrom = folderGetDialog('From');
dirTo = folderGetDialog('To');
c = dirFrom.copy2(dirTo);
P.S. How do you post text as a code? I mean green color and borders around text
My friend have written for me a function of copying folders

If it is interesting for anybody, here it is:
function my_copy_dir(dest)
{
var dest_obj = new Folder(dest);
if(!dest_obj.exists)
{
dest_obj.create();
}
var files = this.getFiles();
for(var i = 0;i<files.length;i++)
{
files.copy2(dest_obj.absoluteURI+'/'+files.name);
}
}
function my_copy_file(dest)
{
  this.copy(dest);
}
Folder.prototype.copy2 = my_copy_dir;
File.prototype.copy2 = my_copy_file;
dirFrom = folderGetDialog('From');
dirTo = folderGetDialog('To');
c = dirFrom.copy2(dirTo);
P.S. How do you post text as a code? I mean green color and borders around text
To post as code, select the text and hit the "code" button above the editing box.
Code: Select all
test code;