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

Javascript - Get metadata from title and save the file name as the title.

Community Beginner ,
Jan 31, 2022 Jan 31, 2022

Hello hopefully someone can help. I've got some javascript i'd like to run. Basically I'd like to get the title of the pdf and save the file as that name. I've found some javascript on how to edit the title

e.g.

this.info.title = "My Summer Vacation"; // Set the Document Title 

and also how to save as a given name

this.saveAs("/c/MyDocs/" + this.documentFileName);

  and I've tried to combine them by doing this:

this.saveAs("C:/FILELINK/" + this.info.title);

but this isn't working. Does anyone have any ideas please?

TOPICS
JavaScript
2.3K
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
1 ACCEPTED SOLUTION
Community Expert ,
Jan 31, 2022 Jan 31, 2022

I see a couple of issues, yes.

- From what context are you running the code? The saveAs method requires privileged context.

- Your file path has an incorrect syntax, plus it's missing the file extension. Try this:

this.saveAs("/C/FILELINK/" + this.info.title + ".pdf");

 

If something is not working it will be helpful to specify what exactly happens when you try it.

There's probably an error message, so what does it say?

View solution in original post

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 ,
Jan 31, 2022 Jan 31, 2022

I see a couple of issues, yes.

- From what context are you running the code? The saveAs method requires privileged context.

- Your file path has an incorrect syntax, plus it's missing the file extension. Try this:

this.saveAs("/C/FILELINK/" + this.info.title + ".pdf");

 

If something is not working it will be helpful to specify what exactly happens when you try it.

There's probably an error message, so what does it say?

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 ,
Jan 31, 2022 Jan 31, 2022

Thank you so much, that worked perfectly!

I'm running it from the Action Wizard and it wasn't throwing up any error messages unfortunately. 

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 ,
Jan 31, 2022 Jan 31, 2022
LATEST

Press Ctrl+J and you'll see the error message there.

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