Copy from folder to folder in Javascript
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
Open the file and save it in the other folder.
Copy link to clipboard
Copied
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 { }
}
}
Copy link to clipboard
Copied
But this script does not work...
Copy link to clipboard
Copied
You must define the functions at folder level. Then use the functions in your script.

