Skip to main content
madhusudhananc
Known Participant
January 4, 2018
Answered

Saving Document in Folder Name

  • January 4, 2018
  • 1 reply
  • 1755 views

How to save a file using the folder name? In the below code i want to replace the "test" with my source PDF folder name. How to do that?

newDoc.saveAs("/c/temp/test.xlsx", "com.adobe.acrobat.xlsx");

This topic has been closed for replies.
Correct answer Thom Parker

Thanks Thom for your reply. If the source PDF is current document then how to proceed?. In case if i don't know my source PDF folder how to proceed on this?


If the source is the current pdf then you just split the folder path and extract the last folder name.

Here's an article that shows a technique for manipulating path elements:

https://acrobatusers.com/tutorials/splitting-and-rebuilding-strings

If you know the source PDF, then you know the folder.  The full path to the PDF is a document property, as shown in the article.

1 reply

try67
Community Expert
Community Expert
January 4, 2018

Do you mean that you want to use the file's current folder? If so, then use this code:

newDoc.saveAs(newDoc.path.replace(newDoc.documentFileName, "text.xlsx"), "com.adobe.acrobat.xlsx");

madhusudhananc
Known Participant
January 4, 2018

No Try, I want to save the excel file in the name of my source pdf folder. For example my source pdf folder path is c/MyDocs/mysource.pdf. I want to save the excel file with name as MyDocs.xlsx instead of test.xlsx

try67
Community Expert
Community Expert
January 4, 2018

I don't understand what you mean... What is this "source file"? Do you have a variable referencing it?