Skip to main content
sudheerk20144061
Known Participant
March 29, 2019
Answered

A file copy from one location to another

  • March 29, 2019
  • 2 replies
  • 3259 views

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

This topic has been closed for replies.
Correct answer r-bin

Ran the PS with administrator rights and Always getting "I/O error"


"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.

2 replies

Legend
March 29, 2019

sudheerk20144061
Known Participant
March 29, 2019

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");

sudheerk20144061
Known Participant
March 29, 2019

// folder

var srcipt_folder = new File($.fileName).parent;

// string with path

var srcipt_folder_path = new File($.fileName).parent.fullName;

ps. updated


Thank you thank you so much

Really thank you r-bin for your kindly help ....

sudheerk20144061
Known Participant
March 29, 2019

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