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

Cannot create link from the given URI based on the folder Path

Participant ,
Jul 11, 2023 Jul 11, 2023

Hi,

I have used the script to get the image link's path. For a month it's working fine in the InDesign previous versions but by using the latest version of InDesign I can't able to retrieve the image path. I have attached the script which I used to retrieve the image path

var doc = app.activeDocument;
// Loop through all the links in the document
  var link = doc.links[0];
  // Get the file path of the linked image
  var filePath = link.filePath;
  // Create a File object from the file path
  var file = new File(filePath);
  // Get the folder path of the file
   folderPath = file.parent.fsName;

 

-Monisha
TOPICS
How to , Scripting
140
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 ,
Jul 11, 2023 Jul 11, 2023

What are we supposed to understand by "can't able to retrieve the image path"? Please provide more details like

  • Do you get an error? If so what is it?
  • Does it execute but the result is not as per your expectation?
  • Did you try the same code and same Indd file in different versions of InDesign and got different results. If yes then please let us know the InDesign versions and also share the code/indd file to test with.

-Manan

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 ,
Jul 11, 2023 Jul 11, 2023
LATEST

Hi @MonishaRajendran , Did you try checking the returned paths via a $.writeln()? You could simplify with this, but what you have should work.

 

var doc = app.activeDocument;

//a test link on the desktop
var link = doc.links[0];

//link as a file
var file = new File(link.filePath);

//link file’s parent folder
var folderPath = file.parent

$.writeln(file)
//returns ~/Desktop/testlink.png

$.writeln(folderPath)
//returns ~/Desktop

 

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