No, since you have the PDF open, you cannot rename it.
What content are you going to use?
It could be saved under a new name using form fields or the PDF properties of key words, subject, or title if the properties are field in for the PDF. But this type of coding will require some special code in folders.
All my files have key words on the same place. And saving them under a new correct name is what im looking for. Can I send you an example of the pdf that would need to be renamed?
We are here to help you with script problems not write the entire script for you.
So the script below just saves your pdf as "x" in the same location. But how can I change this X into a value/text present on my PDF?
// Split Path into an array so it is easy to work with
var aMyPath = this.path.split("/");
// Remove old file name
// Add new file name
// Put path back together and save
How is renaming PDF files with JS doable, tedious or not?
If it is necessary to extract text from a specific location on a page in order to use it in the output file name, then the algorithm is as follows:
1. First, use a ruler/grid tool (Use Ctrl+U and Ctrl+R keyboard shortcuts to toggle the tools on/off) to determine the coordinates on the page where the "text of interest" is located. If there are multiple areas, measure each one and record the coordinates.
3. Check each "quad" returned by the function against the area(s) of interest (determined manually in step 1). Complication: it is necessary to take page rotation and difference in coordinate systems into account when checking each quad. Quads are returned in the page coordinate system (user space, origin is in bottom-left corner), while coordinates on screen are measured in screen coordinate system (device space, origin is in upper-left corner, y-axis is pointing down).
4. If the word lies inside an "area of interest", add it to the output text string.
5. Once done enumerating the words, save the file using this.SaveAs() method while combining a predefined output path with the extracted text.
1. Coordinates for the text needs to be measured manually.
2. If new documents with a different layout are used, then the script needs to be edited with new coordinates.
3. Can be a very slow process if there is a lot of text and a lot of files involved.
The similar script can be used if the text of interest conforms to a well-defined text pattern (such as SSN, account number, client ID, email and etc.). Then there is no need to measure text coordinates and text can be extracted by performing a text search. In this case, all words need to be enumerated using this.getPageNthWord() method and the resulting text string can be searched using a regular expression.
I know all of that, but it's not what I asked about. I asked specifically about renaming files, which you said is possible.
AFAIK, JS can only save a file under a new name; It can't rename an existing file.
I agree. Just wanted to make sure there isn't some kind of hidden feature I was not aware of that allowed it...