Skip to main content
iBabs2
Inspiring
December 18, 2017
Answered

Removing the suffix from an Image name via inset text variable

  • December 18, 2017
  • 3 replies
  • 3869 views

Hello,

If I want to use the variable option to Insert the Image Name, via - Type Menu-Text Variable - Image Name, is there a way to get the Image Name to appear without the suffix (.psd, .jpg etc..).

thank you,

Babs

This topic has been closed for replies.
Correct answer iBabs2

Hi Vinny,

Thank you for the article... It looks like I may need to convert all the variables to static captions first... In which case this looks like it will work. I was trying too avoid this, as these documents can be ongoing and would have to doing this each time we added images.

But, it may be the only way.....

I will test this tomorrow when at this client..

thank you all,

Babs

3 replies

Doug A Roberts
Community Expert
Community Expert
December 19, 2017

when I had to do this, I cheated -- i applied a character style with no fill colour via GREP to the file extensions I was using (.ai, .jpg, .png)

the text is still there though of course, but it was fine for my purposes to hide it.

iBabs2
iBabs2Author
Inspiring
December 19, 2017

Hi Doug…..

Yes, it is a bit of a cheat, but will look at this option as well. The only thing that may halt this option, is sometimes the copy will be over a textured background? If that is the case, this will be an issue. But, if it is over a solid color background, this would be a good work around.

Thank you!
babs

iBabs2
iBabs2Author
Inspiring
December 24, 2017

Hi Babs:

Let us know what you find over in the scripting arena, and keep in mind that you can use GREP styles on static captions, but not on variables or live captions.

~Barb


Hi Barb,

Got some help in the Bridge area for scripting: This worked in Bridge:

  1. #target bridge    
  2.    if( BridgeTalk.appName == "bridge" ) {   
  3. fileToDesc = MenuElement.create("command", "Add FileName to Description", "at the end of Tools"); 
  4. fileToDesc.onSelect  = function () {    
  5. var thumbs = app.document.selections;  
  6. if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript"); 
  7. for(var a =0;a<thumbs.length;a++){ 
  8. var selectedFile =  new Thumbnail(thumbs);     
  9. app.synchronousMode = true
  10. var xmp = new XMPMeta(selectedFile.synchronousMetadata.serialize()); 
  11. var Desc = getArrayItems(XMPConst.NS_DC, "description"); 
  12. if(Desc != "") Desc+= ";"
  13. xmp.deleteProperty(XMPConst.NS_DC, "description");  
  14. xmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", Desc +=  decodeURI(selectedFile.spec.name).replace(/\..+$/,"")); 
  15. var newPacket = xmp.serialize(XMPConst.SERIALIZE_USE_COMPACT_FORMAT); 
  16. selectedFile.metadata = new Metadata(newPacket);  
  17.     } 
  18. ExternalObject.AdobeXMPScript.unload(); 
  19. ExternalObject.AdobeXMPScript = undefined; 
  20. function getArrayItems(ns, prop){ 
  21. var arrItem=[]; 
  22. try
  23. var items = xmp.countArrayItems(ns, prop); 
  24. for(var i = 1;i <= items;i++){ 
  25. arrItem.push(xmp.getArrayItem(ns, prop, i)); 
  26. return arrItem.toString(); 
  27. }catch(e){alert(e +" Line: "+ e.line);} 
  28.     } 
  29. }

Babs

vinny38
Legend
December 19, 2017
iBabs2
iBabs2AuthorCorrect answer
Inspiring
December 19, 2017

Hi Vinny,

Thank you for the article... It looks like I may need to convert all the variables to static captions first... In which case this looks like it will work. I was trying too avoid this, as these documents can be ongoing and would have to doing this each time we added images.

But, it may be the only way.....

I will test this tomorrow when at this client..

thank you all,

Babs

vinny38
Legend
December 19, 2017

Possibly a Photoshop script could copy the filename (with no extension) into the Title metadata.

Then, Barb's suggestion would work fine.

But this is way beyond my skills.

Maybe you could post a request in the Photoshop scripting forum?

Photoshop Scripting

Community Expert
December 18, 2017

Hi Babs,

you could try to remove the suffix after creating the captions.


But that would require to use the static version of the functionality so that the every character of your image name is editable. Then you could do a find/change action with a GREP pattern to remove the suffix by means of your applied paragraph style that should be unique to your captions.

One example:

GREP find pattern if the image name is at the very end of the caption:

Your applied paragraph style plus:

\..{2,4}\z

( That would find a dot followed by 2 to 4 characters at the end of a story. Placed graphics could be include e.g. .ai , .pdf , .jpg , .jpeg etc.pp. )

replace with a dot perhaps:

\.

Or with nothing if you do not want a character after the name of a placed graphic at the end.

Regards,
Uwe

iBabs2
iBabs2Author
Inspiring
December 18, 2017

Hello Uwe,

That would work great, except that these are being made with the Insert variable "image name", not a caption. Which doesn't seem to find anything? I can't even use the Find/Change to just find the word .jpg?

Do you know if variables can be searched? Maybe they cannot be changed?

thanks!

Babs

Barb Binder
Community Expert
Community Expert
December 19, 2017

Change the metadata from Name to Title.

EDIT: My mistake. I didn't realize the document title was defined in the metadata in the two files I tested last night. I'm am assuming you don't want to add metadata (and that it isn't already provided).

~Barb

~Barb at Rocky Mountain Training