Trick: replace a file without changing the DT link

Here is a trick I want to share:
We can replace a file with its DT link unchanged.

  1. Right click the file and click on show in Finder to find the file in finder
  2. Replace the file there and make sure the old and new file have the same file name

Application situation:
I use DT to track my scientific project and record all the figures. Sometimes I need to update a figure because I add some new lines or I did something wrong on the previous figure. However, I already refer to this figure in my note using this DT link, so I need to replace the figure without changing the DT link.

Last word:
I know it is not recommended to modify the database directly, but otherwise I need to modify all the DT links in my note and that is annoying. I hope that DT can add a function that we can replace a file without changing the DT link so that I can avoid this dangerous operation.

3 Likes

True, oh so true. What do you do if that breaks the database?

There might be alternatives.

  • You could open the figure from DT in your favorite figure changing app, apply your changes there and save it again. That way, only the content changes, not DT’s UUID
  • You could store your figures in an external folder (i.e. external to DT) and index that. Then, modify your figures with your favorite figure modification app and update the index in DT.

I suggest that you try that instead of jeopardizing the integrity of your data.

2 Likes

As long as the filetype & filename are identical, this shouldn’t break anything. But I would also recommend to simply edit the file (in DEVONthink or externally).

What about the new checksum integrity stuff? Will it fail when verifying the DB?

DEVONthink should automatically update the index and checksum after receiving the filesystem event. If that should fail (e.g. if the volume containing the databases doesn’t support it reliably), then File > Update Indexed Items should help.

1 Like

Thank you for the suggestions!

I will try to use the linked file method.
I cannot directly modify the figure since these figures are automatically produced by some Python program.

I still have one question. How DT distinguish that a file is modified by external application and replaced by me. Is there any system-wise ID that stays unchanged with modification and changed with substitution?

I tried my method and it works. So I come to a theory that the DT link only depends on the relative path and the name of a file, and it does not depend on the content of this file.

If the DT link depends on the content of this file, then it is impossible for us to modify the file using external application with DT link unchanged.

DEVONthink usually receives a filesystem event and automatically handles this, otherwise use File > Update Indexed Items as suggested (even if it’s not indexed).

Let me repeat your word to make sure that I understand it correctly.

My replace-file-trick works as long as the filetype+filepath+filename do not change. And it will be safer if I run a Update Indexed Items operation, which will do some check for the file, even if they are not indexed.

That’s right.

As mentioned previously: why aren’t you just editing the file in the external application? This is the advocated and safest method.

1 Like

They said already: the files are produced by a python program.

Ahh… I missed that. Thanks!

Thanks!

I have a few cases where a PDF is replicated to 3 or more locations in a database.

When I get an updated version of the PDF, I have to delete all the old version (replicants) and replace.

Up to now I have always deleted all replicants, added the new file and then replicated the new file to the locations accordingly. Time-consuming, but I have never found another way.

I tried the above and it works very well. Unless I have missed an easier way, then I think I’ll try doing this in future (very carefully of course…)

Yes, please be careful indeed.