# Autolink files with key only at the beginning of the file

**URL:** <https://discourse.jabref.org/t/autolink-files-with-key-only-at-the-beginning-of-the-file/147>\
**Category:** Help\
**Created:** [August 16, 2016, 12:52pm UTC](https://discourse.jabref.org/t/autolink-files-with-key-only-at-the-beginning-of-the-file/147 "2016-08-16T12:52:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wolfson](https://avatars.discourse-cdn.com/v4/letter/w/a87d85/32.png) [@Wolfson](https://discourse.jabref.org/u/Wolfson)\
**Post date:** [August 16, 2016, 12:52pm UTC](https://discourse.jabref.org/t/autolink-files-with-key-only-at-the-beginning-of-the-file/147/1 "2016-08-16T12:52:05Z")

</div>

There is an option in Preferences-\>External programs to “Autolink files with names starting with the BibTeX key”. I want to have that option activated, but instead of the “BibTeX key”, with the “key”. I therefor want to use the Regular Expression Search but honestly, I’m not sure how to exactly adjust the field.  
`**/.*[key].*\\.[extension]`  
searches for the key in the whole file-name. How do I have to change the expression that it only looks at the beginning of the file?

Thanks in advance for your help!

---

<div class="post-metadata">

**Author:** ![matthiasgeiger](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/matthiasgeiger/32/7_2.png) [@matthiasgeiger](https://discourse.jabref.org/u/matthiasgeiger)\
**Post date:** [August 16, 2016, 2:02pm UTC](https://discourse.jabref.org/t/autolink-files-with-key-only-at-the-beginning-of-the-file/147/2 "2016-08-16T14:02:46Z")

</div>

Hi!

I do not really understand what you mean with “the ‘key’” - by default JabRef is only working “bibtexkeys”… Do you have a customized field named “key”?

However, adapting the expression to `**/[key].*\\.[extension]` (i.e., removing `.*` before the `[key]`) should work… 😉

Regards  
Matthias

---

<div class="post-metadata">

**Author:** ![Wolfson](https://avatars.discourse-cdn.com/v4/letter/w/a87d85/32.png) [@Wolfson](https://discourse.jabref.org/u/Wolfson)\
**Post date:** [August 17, 2016, 5:02am UTC](https://discourse.jabref.org/t/autolink-files-with-key-only-at-the-beginning-of-the-file/147/3 "2016-08-17T05:02:48Z")

</div>

Hi Matthias,

you’re right, I totally forgot that “key” is not an official field but a custom one that I set up. Anyway, your solution works, thanks a lot for your help!

Best wishes,  
Wolfson
