Copy link to clipboard
Copied
Hello friends,
How can I copy a file from one location to another jut like a windows "copy" command from the script?
copy c:\data\file1.doc D:\backup\file2.doc
"C:\\testing" is the name of the file, not the folder.
If the folder "C:\\testing" exists, there will be an error.
Change code
var bf2=new File("C:\\design\\" +"default_mesh.bin");
if (!bf2.copy ("C:\\testing" + "\\" + "default_mesh.bin")) alert(bf2.error);
else alert("OK!");
In this case, the error will be if the folder "C:\\testing" does not exist.
It is necessary to check the presence of the folder and in case of absence, create a folder.
Copy link to clipboard
Copied
Actually my requirement is to write a bin file.
I tried below way but its not the bin file as i expected:
pseudo code:
array_temp = [0x80,0x90,.......]
var bf2=new File(exportFolder + "\\" + output_FileName+".bin");
bf2.encoding = "BINARY";
bf2.open("w", "b", "");
for(var i = 0; i < array_temp.length; i++)
{
bf2.write(array_temp);
}
bf2.close();
Output bin is something look like below:
31 32 38 --> which is output value of hex 0x80 --> 128dec --> 1 ->0x31, 2--> 0x32, 8 --> 0x38
Copy link to clipboard
Copied

Copy link to clipboard
Copied
I tried to do copy as you suggested, but it didn't worked.
my code:
var bf2=new File("C:\\design\\" +"default_mesh.bin");
bf2.copy ("C:\\testing");
Copy link to clipboard
Copied
var bf2=new File("C:\\design\\" +"default_mesh.bin");
if (!bf2.copy ("C:\\testing")) alert(bf2.error);
else alert("OK!");
Copy link to clipboard
Copied
Ran the PS with administrator rights and Always getting "I/O error" ![]()
Copy link to clipboard
Copied
"C:\\testing" is the name of the file, not the folder.
If the folder "C:\\testing" exists, there will be an error.
Change code
var bf2=new File("C:\\design\\" +"default_mesh.bin");
if (!bf2.copy ("C:\\testing" + "\\" + "default_mesh.bin")) alert(bf2.error);
else alert("OK!");
In this case, the error will be if the folder "C:\\testing" does not exist.
It is necessary to check the presence of the folder and in case of absence, create a folder.
Copy link to clipboard
Copied
Thank you soooooooo much it works finally ![]()
Copy link to clipboard
Copied
r-bin, one more small request, how can i find my script(*.jsx) path ?
Copy link to clipboard
Copied
// folder
var srcipt_folder = new File($.fileName).parent;
// string with path
var srcipt_folder_path = new File($.fileName).parent.fullName;
ps. updated
Copy link to clipboard
Copied
Thank you thank you so much ![]()
Really thank you r-bin for your kindly help ....
Copy link to clipboard
Copied
If you have some sample code can you please share me
Find more inspiration, events, and resources on the new Adobe Community
Explore Now