# Move folder with PDFs and have JabRef reconnect links to them automatically

**URL:** https://discourse.jabref.org/t/move-folder-with-pdfs-and-have-jabref-reconnect-links-to-them-automatically/2285
**Category:** Help
**Created:** [September 7, 2020, 1:19pm UTC](https://discourse.jabref.org/t/move-folder-with-pdfs-and-have-jabref-reconnect-links-to-them-automatically/2285 "2020-09-07T13:19:14Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![And](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@And](https://discourse.jabref.org/u/And)
#### Post date: [September 7, 2020, 1:19pm UTC](https://discourse.jabref.org/t/move-folder-with-pdfs-and-have-jabref-reconnect-links-to-them-automatically/2285/1 "2020-09-07T13:19:14Z")

</div>

Hi there,

As is written in the subject, is there a possibility to move a folder (while keeping its structure intact and/or different) with my PDFs and have JabRef reconnect links to them automatically after the fact?

For example, move

\level 1\level 2\PDFs\  
to  
\level1\PDFs\  
or to  
\newfolder\newsubfolder\PDFs\

and suffer no consequences?

I would’ve tried on my own, but I’m afraid to mess up with the database and then not being able to go back. Yes, I know I can create a copy of it, but still it’s better to ask.

---

<div class="post-metadata">

### Author: ![Siedlerchr](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/siedlerchr/32/216_2.png) [@Siedlerchr](https://discourse.jabref.org/u/Siedlerchr)
#### Post date: [September 7, 2020, 5:25pm UTC](https://discourse.jabref.org/t/move-folder-with-pdfs-and-have-jabref-reconnect-links-to-them-automatically/2285/2 "2020-09-07T17:25:04Z")

</div>

HI,

welcome to the wonderful magic fature of JabRef, renaming and moving files 😉  
It’s definitely advisable to create a copy of your bib file.

JabRef can rename files, create directories and move files to those directories, it’s very flexible, but depends on how you organize your files.

1. Do you have a sinlge folder where you put alll your pdf?  
Then it’s probaly simple. Just change the main file directory in the preferences to the new one and to a Cleanup -\> move files to folder. Then JabRef should move the files to the folder.

Before you do this for all files using the Cleanup operation it’s advisable to test it with a single entry first.  
Right click the file in the gernal tab -\> Move

---

<div class="post-metadata">

### Author: ![And](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@And](https://discourse.jabref.org/u/And)
#### Post date: [September 8, 2020, 7:05am UTC](https://discourse.jabref.org/t/move-folder-with-pdfs-and-have-jabref-reconnect-links-to-them-automatically/2285/3 "2020-09-08T07:05:22Z")

</div>

Hi Cristoph and thanks for your reply.

My organization is like this: I have a main folder which doesn’t contain any PDFs, but only the folder structure (organized thematically). The PDFs are located down in the subfolders, at multiple levels.

Finally, all PDFs are named according to my own naming scheme (i.e. Author - Title . Subtitle [year].pdf) that I’d like to keep.

Is there a possibility I move somewhere else the whole main folder with the structure and naming as they are now, and then just make JabRef relink them as they were?

I guess the alternative would be to replace the path string inside the .bib file for each entry, which I would avoid doing unless absolutely necessary.

---

<div class="post-metadata">

### Author: ![koppor](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/koppor/32/5_2.png) [@koppor](https://discourse.jabref.org/u/koppor)
#### Post date: [July 5, 2021, 9:43pm UTC](https://discourse.jabref.org/t/move-folder-with-pdfs-and-have-jabref-reconnect-links-to-them-automatically/2285/4 "2021-07-05T21:43:47Z")

</div>

Each users organizes the files slightly different. If you have the file paths stored relatively in the .bib file, this is no issue. If not, you can use the cleanup action to convert the paths to relative ones (see [https://docs.jabref.org/finding-sorting-and-cleaning-entries/cleanupentries](https://docs.jabref.org/finding-sorting-and-cleaning-entries/cleanupentries)).

Then you can use the preferences of the current library to change the starting search path: [https://docs.jabref.org/faqgeneral#q-how-do-i-link-external-files-with-paths-relative-to-my-bib-file-so-i-can-move-my-library-along-with-its-files-to-another-directory](https://docs.jabref.org/faqgeneral#q-how-do-i-link-external-files-with-paths-relative-to-my-bib-file-so-i-can-move-my-library-along-with-its-files-to-another-directory)

Then, it should be no issue to move around the diretory.

---

<div class="post-metadata">

### Author: ![And](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@And](https://discourse.jabref.org/u/And)
#### Post date: [August 29, 2021, 5:51pm UTC](https://discourse.jabref.org/t/move-folder-with-pdfs-and-have-jabref-reconnect-links-to-them-automatically/2285/5 "2021-08-29T17:51:39Z")

</div>

Hi there,

I am resurrecting this (kinda) old thread.

I recently did a reorganisation of my PDF files and folder structure. What this means is that I moved them to other places, did some reshuffling, etc. but all PDF filenames remained the same.

I also tried to clean up the database (as suggested above by @koppor) and to make PDF paths relative. Unfortunately, this did not make PDF paths relative as I can see that they are still fixed as they were.

EDIT: I also just discovered and tried the **Automatically set file links** option in the Quality menu, to no avail. Mind that in Library → Library properties the General file directory is set to “.” i.e. the directory where the .bib file is located. But JabRef still cannot find the files anyway. It just searches for the files and then says: **Finished automatically setting file links. No files found.**

What I need to do, actually, is to reconnect all the entries in my .bib database to the original PDF files that were shuffled around. Is this possible at all? Can JabRef rediscover them automatically by filename i.e. author - title [year].pdf?

---

<div class="post-metadata">

### Author: ![Siedlerchr](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/siedlerchr/32/216_2.png) [@Siedlerchr](https://discourse.jabref.org/u/Siedlerchr)
#### Post date: [August 30, 2021, 9:30am UTC](https://discourse.jabref.org/t/move-folder-with-pdfs-and-have-jabref-reconnect-links-to-them-automatically/2285/6 "2021-08-30T09:30:07Z")

</div>

Hi,

Have you **unchecked** the option “Search and store files relative to library locaiton”?  
This takes precedence over all other options.  
And you also need to set the filename format pattern in the preferences under LInked files then to [author] - [title] - [year]

---

<div class="post-metadata">

### Author: ![And](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@And](https://discourse.jabref.org/u/And)
#### Post date: [August 30, 2021, 11:51am UTC](https://discourse.jabref.org/t/move-folder-with-pdfs-and-have-jabref-reconnect-links-to-them-automatically/2285/7 "2021-08-30T11:51:30Z")

</div>

Thanks, I’ll try it and let you know how it went.

BTW why does this have to be so complex and fiddly? All entries already have the filename in them. JabRef can simply search for that filename within a folder structure and discover all files. If there are conflicts, it can simply show a window picker so that the user can resolve them manually (just like with fetching data).

---

<div class="post-metadata">

### Author: ![Siedlerchr](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/siedlerchr/32/216_2.png) [@Siedlerchr](https://discourse.jabref.org/u/Siedlerchr)
#### Post date: [August 30, 2021, 12:53pm UTC](https://discourse.jabref.org/t/move-folder-with-pdfs-and-have-jabref-reconnect-links-to-them-automatically/2285/8 "2021-08-30T12:53:48Z")

</div>

Hi,

sorry for the confusion, I mixed the dialogs up.

JabRef does exactly that, it looks for the files in the folders, that is exactly what the Automatically set linked files does. It’s controlled by these options:

 ![grafik](https://canada1.discourse-cdn.com/flex030/uploads/jabref/original/2X/d/d7b790596f4854c9de13bc441fef72d4368f5e68.png)

This prevents it from taking up any other unwanted files.

---

<div class="post-metadata">

### Author: ![And](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@And](https://discourse.jabref.org/u/And)
#### Post date: [August 30, 2021, 2:00pm UTC](https://discourse.jabref.org/t/move-folder-with-pdfs-and-have-jabref-reconnect-links-to-them-automatically/2285/9 "2021-08-30T14:00:07Z")

</div>

Hi Christoph,

Thanks for attempting to help me. Unfortunately, what you suggested doesn’t work i.e. JabRef finds no files. ☹

It seems that I’ll have to do this with another, external script or software of a sort. One that would search for strings in the .bib database ending in .pdf, then find the location of the matching filename, and then replacing the path in the .bib database.

Do you have any idea what software can I try for this purpose?

---

<div class="post-metadata">

### Author: ![Siedlerchr](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/siedlerchr/32/216_2.png) [@Siedlerchr](https://discourse.jabref.org/u/Siedlerchr)
#### Post date: [August 30, 2021, 2:15pm UTC](https://discourse.jabref.org/t/move-folder-with-pdfs-and-have-jabref-reconnect-links-to-them-automatically/2285/10 "2021-08-30T14:15:44Z")

</div>

Oh no. We can get this working together!  
First of all, try the latest development version of JabRef. [index - powered by h5ai v0.29.0 (https://larsjung.de/h5ai/)](https://builds.jabref.org/main/)

Then I need the path info about the location of the pdf and second the path of the bib file. Then I can tell you more

---

<div class="post-metadata">

### Author: ![Shauna\_GM](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/shauna_gm/32/1403_2.png) [@Shauna\_GM](https://discourse.jabref.org/u/Shauna_GM)
#### Post date: [June 23, 2022, 12:14am UTC](https://discourse.jabref.org/t/move-folder-with-pdfs-and-have-jabref-reconnect-links-to-them-automatically/2285/11 "2022-06-23T00:14:56Z")

</div>

I’m having a very similar problem. I just set up Jabref a few days ago, and linked a bunch of papers that I have in a folder on my Desktop. Then I downloaded a bunch of files from online, which Jabref automatically put in its own folder. Wanting to store all the files in the same folder, I moved everything to a third folder, not realizing it would break all my links within Jabref. I wish I’d seen this thread before I started!

I have done the following:

- set the main file directory to the new directory
- unchecked “Search and store files relative to library locaiton”
- changed the “linked files” \> “Autolink files” preference to “Use regular expression search”, per @Christoph’s screenshot
- ran “Automatically set file links” in the Quality menu

Like “And” above, I get “Finished automatically setting file links. No files found.”

The files are now located in “/home/shauna/Desktop/misc/readings”. The bib file is in “/home/shauna/snap/jabref/1631” which appears to have been created on installation/first run. The bib file upon inspection is using full paths refering to the old folder structure.

Jabref version: JabRef 5.6–2022-04-25–5c9d898  
Linux 5.13.0-51-generic amd64  
Java 17.0.2  
JavaFX 18+12

---

<div class="post-metadata">

### Author: ![ThiloteE](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/thilotee/32/1008_2.png) [@ThiloteE](https://discourse.jabref.org/u/ThiloteE)
#### Post date: [June 23, 2022, 10:03am UTC](https://discourse.jabref.org/t/move-folder-with-pdfs-and-have-jabref-reconnect-links-to-them-automatically/2285/12 "2022-06-23T10:03:45Z")

</div>

Reading your comment, @Shauna_GM , I think what you did looks already pretty good. I am not sure why it does not work. I think it should.

I have a suspicion, though:

Keep in mind, regular expression search (RegEx search) depends on the filenames of your PDFs. If the filename does not match your RegEx, nothing will be found.

You can create very complicated RegEx patterns to detect very complicated filenames. The Syntax JabRef uses mainly follows citationkey patterns as described here: [Customize the citation key generator - JabRef](https://docs.jabref.org/setup/citationkeypatterns#regular-expressions-regex)  
See also [Searching within the library - JabRef](https://docs.jabref.org/finding-sorting-and-cleaning-entries/search#advanced-use-of-regular-expressions)

If my suspicion is right and the RegEx does not detect your file-names, I would suggest to adapt your RegEx to fit your current file-names or alternatively to rename your PDF files to fit your current regex.

---

<div class="post-metadata">

### Author: ![ThiloteE](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/thilotee/32/1008_2.png) [@ThiloteE](https://discourse.jabref.org/u/ThiloteE)
#### Post date: [June 23, 2022, 10:14am UTC](https://discourse.jabref.org/t/move-folder-with-pdfs-and-have-jabref-reconnect-links-to-them-automatically/2285/13 "2022-06-23T10:14:07Z")

</div>

Alternatively, you can use the `Edit > Find and replace (CTRL + R)` tool to replace your old folder structure in the file field with your new folder structure.

Example:

 ![grafik](https://canada1.discourse-cdn.com/flex030/uploads/jabref/original/2X/f/f32008c64330bc3844a04e02561ee156948b5b32.png)

---

<div class="post-metadata">

### Author: ![Shauna\_GM](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/shauna_gm/32/1403_2.png) [@Shauna\_GM](https://discourse.jabref.org/u/Shauna_GM)
#### Post date: [June 23, 2022, 10:10pm UTC](https://discourse.jabref.org/t/move-folder-with-pdfs-and-have-jabref-reconnect-links-to-them-automatically/2285/14 "2022-06-23T22:10:36Z")

</div>

The find and replace ended up being the simplest solution. (I did try fiddling with the regex, but doing so caused “Automatically set file links” option to become greyed out/inaccessible. Maybe my fiddling led to invalid regexes? It looked right but regexes are capricious beasts.) Anyway, thank you so much for the help!
