These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to strip extension from filename in dynamic stamp

scarymon
Registered: Jan 6 2011
Posts: 2
Answered

I have a dynamic stamp that I want to populate the filename without the extension and add it to the meta data as well. I have tried several ways, but I just can’t seem to get it working. Here is the code I am using. The first line alone works fine for putting the filename in the field, but I can’t seem to display it without the extension.
 
event.value = event.source.source.documentFileName;
var foo = this.getField("ExhibitNumField").value;
foo = foo.substring(0, foo.lastIndexOf('.'));
event.source.source.info.foo = cMsg;
 
Any ideas?

My Product Information:
Acrobat Pro 9.4, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
Use this:

event.value = event.source.source.documentFileName.replace(/\.pdf$/i,"");

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

scarymon
Registered: Jan 6 2011
Posts: 2
This worked great. Thanks.