Script
Learn / Forums / General InDesign Topics / Script
Tagged: scripts
- This topic has 6 replies, 5 voices, and was last updated 5 years ago by Jeremy Howard.
-
AuthorPosts
-
-
September 13, 2018 at 7:20 am #110385Julie ShafferParticipant
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?
-
September 13, 2018 at 10:25 am #110394David BlatnerKeymaster
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.
-
September 13, 2018 at 12:12 pm #110400Julie ShafferParticipant
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!
-
September 14, 2018 at 5:10 am #110403Vinny –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 -
March 25, 2019 at 1:31 pm #115514Pat MoritaMember
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
-
March 27, 2019 at 6:34 pm #115606Jeremy HowardParticipant
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//////////////////////////////////////////////////////// -
March 28, 2019 at 5:31 am #115616Jeremy HowardParticipant
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////////////////////////////////////////////////////////
-
-
AuthorPosts
- You must be logged in to reply to this topic.