Adobe Community
All community
This category
This board
Knowledge base
Users
cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results forÂ
ShowÂ
 onlyÂ
|
Search instead forÂ
Did you mean:Â
Global community
Language:
Deutsch
English
Español
Français
Português
日本語コミュニティ
Dedicated community for Japanese speakers
í•œêµ ì»¤ë®¤ë‹ˆí‹°
Dedicated community for Korean speakers
Sign In
Exit
Home
InDesign
Discussions
Re: JS CS2: Image Link
Home
InDesign
Discussions
Re: JS CS2: Image Link
0
Upvote
JS CS2: Image Link
Guest
/t5/indesign-discussions/js-cs2-image-link/td-p/1148188
Apr 03, 2008
Apr 03, 2008
Copy link to clipboard
Copied
Is it possible to store in a variable the file name of an image that is selected in a document?
Cheers
Norbert
TOPICS
Scripting
Views
407
Translate
Translate
Report
Report
Follow
Report
More
Reply
Reply
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
6 Replies
6
Jump to latest reply
Guest
AUTHOR
/t5/indesign-discussions/js-cs2-image-link/m-p/1148189#M278090
Apr 03, 2008
Apr 03, 2008
Copy link to clipboard
Copied
Sorry forgot to mention that the selected item could be jpeg/pdf/eps tiff.
Regards
Norbert
Votes
0
Upvote
Translate
Translate
Report
Report
Follow
Report
More
Reply
Reply
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Guest
AUTHOR
/t5/indesign-discussions/js-cs2-image-link/m-p/1148190#M278091
Apr 03, 2008
Apr 03, 2008
Copy link to clipboard
Copied
I found this code snippet in the forum but this only works on jpegs or tiffs and not on eps/ai or tiffs.
Any help will be much appreciated.
Cheers
Norbert
var myString = "";
myDoc=app.activeDocument
myImage = myDoc.selection[0].images[0];
myCurrLink = myImage.itemLink;
myName = getFileNameOnly (myCurrLink.name);
alert(myString);
function getFileNameOnly (myFileName)
{
var myResult = myFileName.lastIndexOf(".");
if (myResult == -1)
{
myString = myFileName;
}
else
{
myString = myFileName.substr(0, myResult);
}
}
Votes
0
Upvote
Translate
Translate
Report
Report
Follow
Report
More
Reply
Reply
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Peter Kahrel
Community Expert
,
/t5/indesign-discussions/js-cs2-image-link/m-p/1148191#M278092
Apr 03, 2008
Apr 03, 2008
Copy link to clipboard
Copied
For EPS and AI, use epss[0] instead of images[0]
Peter
Votes
0
Upvote
Translate
Translate
Report
Report
Follow
Report
More
Reply
Reply
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Peter Kahrel
Community Expert
,
/t5/indesign-discussions/js-cs2-image-link/m-p/1148192#M278093
Apr 04, 2008
Apr 04, 2008
Copy link to clipboard
Copied
... but then you need to know the type of image, which could be epss, images, picts, pdfs, or wmfs (maybe some more). It's safer to avoid that and use "graphics" instead:
try
{
alert (File (app.selection[0].graphics[0].itemLink.filePath).name)
}
catch (_)
{
alert ("Selection doesn't contain any images.")
}
Peter
Votes
0
Upvote
Translate
Translate
Report
Report
Follow
Report
More
Reply
Reply
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Guest
AUTHOR
/t5/indesign-discussions/js-cs2-image-link/m-p/1148193#M278094
Apr 06, 2008
Apr 06, 2008
Copy link to clipboard
Copied
Thanks very much Peter!!
Votes
0
Upvote
Translate
Translate
Report
Report
Follow
Report
More
Reply
Reply
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Jay_Sparks_
New Here
,
/t5/indesign-discussions/js-cs2-image-link/m-p/1148194#M278095
Apr 15, 2008
Apr 15, 2008
Copy link to clipboard
Copied
LATEST
Something like this may work too...<br /><br />var filenameVariable = ""; <br />g = app.activeDocument.allGraphics;<br />for (i=0; i<g.length; i++){<br /> if (g
.itemLink == null) {<br /> i++;}<br /> else {<br /> filenameVariable = g
.itemLink.name;<br />}<br />}
Votes
0
Upvote
Translate
Translate
Report
Report
Follow
Report
More
Reply
Reply
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Post Reply
Preview
Exit Preview
never-displayed
You must be signed in to add attachments
never-displayed
Â
Resources
Learn and Support
Adobe InDesign User Guide
Adobe InDesign Learn and Support
Get Started with InDesign
Adobe InDesign | Common Questions
Work with Photoshop files in InDesign
Resources
Tutorials
InDesign system requirements
What's new InDesign
Newsletters
Crash and Slow Performance
Crash on launch
Slow Performance and Unexpected behaviors
Known issues