Skip to main content
hamdifem
Inspiring
September 5, 2015
Answered

only the link file name alert

  • September 5, 2015
  • 1 reply
  • 400 views

A selected object

I just want to alert the name

not the file extension

var mySel = app.activeDocument.selection;

alert (mySel.link.name);

Alert : Flower.eps  (this not)

Alert : Flower   (I want)

This topic has been closed for replies.
Correct answer Peter Kahrel

Ok, the problem is about dealing with the selection on top of displaying the link name without extension. Try this:

mySel = app.selection[0];

alert (mySel.graphics[0].itemLink.name.replace(/(.+)(\..+)$/, '$1'));

Peter

1 reply

Peter Kahrel
Community Expert
Community Expert
September 5, 2015

alert (mySel.link.name.replace (/(.+)\..+$/, '$1'))

P.

hamdifem
hamdifemAuthor
Inspiring
September 5, 2015

thank you very much

ok only file extension

I solved the problem


.replace(/(.+)(\..+)$/, '$1');  alert : flower

.replace(/(.+)(\..+)$/, '$2');  alert : .EPS

but  command does not work

What kind of a command to be written to the selected object

  1. var mySel = app.activeDocument.selection; 
  2. alert (mySel.link.name.replace(/(.+)(\..+)$/, '$1')); //???
Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
September 5, 2015

Ok, the problem is about dealing with the selection on top of displaying the link name without extension. Try this:

mySel = app.selection[0];

alert (mySel.graphics[0].itemLink.name.replace(/(.+)(\..+)$/, '$1'));

Peter