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

Copy from folder to folder in Javascript

Community Beginner ,
Dec 20, 2022 Dec 20, 2022

Hello all,

 

I have 3 types of pdf files in one folder. Each type of pdf files has a unique word. I want to use these unique words to sort out these 3 types of files and copy them in 3 different folders.
But my question is: how can I copy a file from one folder to another by using Java Script in Adobe?

Thank you in advance!

TOPICS
How to , JavaScript
914
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 Expert ,
Dec 20, 2022 Dec 20, 2022

Open the file and save it in the other 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 ,
Dec 20, 2022 Dec 20, 2022

I tried to write a script: 
I am new to JavaScript, so There might be some mistakes:

for (var p = 0; p < this.numPages; p++)
{
var numWords = this.getPageNumWords(p);
for (var i=0; i<numWords; i++) {

var ckWord = this.getPageNthWord(p, i, true);

 

if ( ckWord == "117.00") {
myTrustedSaveAs = app.trustedFunction(function(vDoc)

{

app.beginPriv();

var myPath = "C:\Users\IMANOVR\Desktop\rot\PA1" + "text1Value.pdf";

vDoc.saveAs({cPath: myPath, bCopy: true, bPromptToOverwrite: false});

app.endPriv();

});
}


else if ( ckWord == "FREIGHT") {
myTrustedSaveAs = app.trustedFunction(function(vDoc)

{

app.beginPriv();

var myPath = "C:\Users\IMA\Desktop\rot\PA2" + "text1Value.pdf";

vDoc.saveAs({cPath: myPath, bCopy: true, bPromptToOverwrite: false});

app.endPriv();

});
}


else if ( ckWord == "CREDIT") {
myTrustedSaveAs = app.trustedFunction(function(vDoc)

{

app.beginPriv();

var myPath = "C:\Users\IMA\Desktop\rot\PA3" + "text1Value.pdf";

vDoc.saveAs({cPath: myPath, bCopy: true, bPromptToOverwrite: false});

app.endPriv();

});
}


else { }
}

}

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 ,
Dec 20, 2022 Dec 20, 2022

But this script does not work...

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 Expert ,
Dec 20, 2022 Dec 20, 2022
LATEST

You must define the functions at folder level. Then use the functions in your script.

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