Script

Tagged: 

Viewing 6 reply threads
  • Author
    Posts
    • #110385
      Julie Shaffer
      Participant

      Is there a script to convert file paths to placed images? I have a client that exports data from a database and places it into InDesign, but the data only includes the server path, not the actual images. We would like to run a script that goes to the path, grabs the image, and places it into InDesign. Does this exist?

    • #110394
      David Blatner
      Keymaster

      You could do this with Data Merge, perhaps, but only if the file path were in a CSV file.

      A script to convert the path to an image is certainly possible. Would the image be placed as an inline (anchored) object? How large should it be? Not sure how the script would know all that.

    • #110400
      Julie Shaffer
      Participant

      Thank you, David! I will get more information about how the data is placed specifically. It’s possible the data merge functionality could work. Thank you for the quick response!

    • #110403
      Vinny –
      Member

      Hi.
      Unless I misunderstood the question, I don’t think Data Merge could be of any help.
      Did you mean that the file path is actually just text in your Indd document?
      If so, maybe you can give this script a go: (haven’t tried it though)
      https://kasyan.ho.com.ua/indesign/image/place_images.html

    • #115514
      Pat Morita
      Member

      You also may use professional software like MyDataMerge. We’ve solved that task exactly with it. It can collect all images, put them in a folder and re-link them for the merge automatically. If this is interesting for you contact me for details

    • #115606
      Jeremy Howard
      Participant

      Hey Julie, I just knocked together this little script. It’s super plain and doesn’t contain any error trapping but it should do the trick/give you a good starting point.

      To use this script, select one or more frames that contain file paths as text and run it. The images will automatically be placed in each of the selected frames!

      //Begin Script//////////////////////////////////////////////////////
      var mySelection = app.selection;
      for(thisItem = 0; thisItem < mySelection.length; thisItem++){
      var currentItem = mySelection[thisItem];
      var frameContents = currentItem.parentStory.contents;
      var myImage = File(frameContents);
      currentItem.place (myImage, false);
      }
      //End Script////////////////////////////////////////////////////////

    • #115616
      Jeremy Howard
      Participant

      Here, I added some checks, this version checks that the selected item(s) is a text frame, will alert you if it finds an invalid file path within the selected frames and will fit placed images to the frame proportionally…

      Enjoy!

      //Begin Script//////////////////////////////////////////////////////
      var mySelection = app.selection;
      for(thisItem = 0; thisItem < mySelection.length; thisItem++){
      var currentFrame = mySelection[thisItem];
      if(currentFrame instanceof TextFrame){
      var frameContents = currentFrame.paragraphs[0].contents;
      var myImage = File(frameContents);
      try{
      currentFrame.place (myImage, false);
      }catch(e){
      alert(“Invalid file path!\r\rThe file \”” + frameContents + “\” could not be found. \rPlease check the file path and try again.” );
      break;
      }
      currentFrame.fit(FitOptions.PROPORTIONALLY);
      }
      }
      //End Script////////////////////////////////////////////////////////

Viewing 6 reply threads
  • You must be logged in to reply to this topic.
>