Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

A file copy from one location to another

Community Beginner ,
Mar 28, 2019 Mar 28, 2019

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

TOPICS
Actions and scripting
3.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Mar 29, 2019 Mar 29, 2019

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

Translate
Adobe
Community Beginner ,
Mar 29, 2019 Mar 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 29, 2019 Mar 29, 2019

Untitled-1.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 29, 2019 Mar 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");

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 29, 2019 Mar 29, 2019
Everything is working.
Run photoshop with administrator rights or use another folder (not a root folder).

Use this code

var bf2=new File("C:\\design\\" +"default_mesh.bin");

if (!bf2.copy ("C:\\testing")) alert(bf2.error);

else alert("OK!");

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 29, 2019 Mar 29, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 29, 2019 Mar 29, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 29, 2019 Mar 29, 2019

Thank you soooooooo much it works finally

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 29, 2019 Mar 29, 2019

r-bin, one more small request, how can i find my script(*.jsx) path ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 29, 2019 Mar 29, 2019

// folder

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

// string with path

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

ps. updated

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 29, 2019 Mar 29, 2019
LATEST

Thank you thank you so much

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 29, 2019 Mar 29, 2019

If you have some sample code can you please share me

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines