Importing from DayOne and changing the name

Hi everyone,

I think this is my first post here, so I want to say hello, I hope everyone is well and enjoying the summer!

Secondly, I want to say how amazed I am how many things can be done with DEVONthink, and the know-how people are sharing on this forum is really appreciated, thanks for that!

I followed explanations by @Stephen_C on this topic: Importing from Day One: a reasonably definitive guide (really great ideas, thank you!)

But I noticed that only some of my files were renamed correctly by DEVONthink.

I tried to understand why and i couldn’t find any reason why some files get renamed and others don’t.

Does anyone know what can cause this?

Thanks in advance for your answers!

Warm regards,
Charlie

Could you be a bit more specific, I’d which files get renamed to what and which ones don’t?

Also, where does the date that you mention in the title come into play?

1 Like

Can you explain any variation from “my process” that you’ve followed, please? It’s difficult to see what’s going wrong without knowing the exact process because it used to work for me!

Since then I’ve substantially changed and improved my process so once I know exactly where it’s tripping over I can probably assist with the “new” process. (I can post the new process later but I’m just about to finish preparing late lunch here - accompanied by a very decent Chardonnay - so it may be a little time before I can type sensibly again! :grin: )

Stephen

1 Like

Welcome @charliecortial!
We are all doing well and staying as cool as possible on both sides of the pond. We hope the same for you.

Secondly, I want to say how amazed I am how many things can be done with DEVONthink, and the know-how people are sharing on this forum is really appreciated, thanks for that!

Indeed! DEVONthink is a very capable application and can be used in a variety of ways, both simple and complex.

1 Like

Thank you all for replying (and so fast)!

To @chrillek, sure, I can try to describe to the best of my ability.
I have 378 Day One entries that I want imported into DEVONthink, following the process outlined by @Stephen_C in the topic linked below.
The process works for me until the renaming of the markdown files. 287 entries don’t get renamed, and the 91 remaining entries do get renamed.
I can’t find any difference between them when I look at them with a text editor. I have no idea why some of them get renamed and others not. Some of the entries have a date in CET time, some in CEST time, it doesn’t seem to make a difference because some got renamed in each group.

You are right about pointing out that mentioning the date in the title is probably wrong. It’s just because the date it’s what I tried to ‘extract’ from the file with DEVONthink, but it seems it’s not related to the date itself.

I don’t really know what else to describe.

To @Stephen_C : As far as I understand, I didn’t vary from the process you outlined at all. I literally followed step by step. I don’t really know what else to add to my description above. Just let me know if I should add something else.
I’m in no hurry, so please enjoy your Chardonnay :grin:

Hi @BLUEFROG, thank you, I’m trying to stay in cool places as well :grin:
It never ceases to amaze me how powerful DEVONthink can be, and how some users come up with amazing workflows!
Creating and bettering an app like that, my panana :grin: off to the DEVONtech team, it’s really mind-boggling.

Thank you all for the time you take to answer me!

Warm regards,
Charlie

1 Like

Charlie:

Do you by any chance use the Hazel app? The whole thing is much easier, and vastly more automated, if you do. (If not, don’t worry, we’ll still try to solve the problem you have.)

In DT select all the imported markdown files (i.e., excluding any photo folder), go to Tools > Batch Process and choose “Change Name” to “Oldest Document Date” (which will pick up the creation date of each entry).

Does it, by any chance, work better if you choose “Newest Document Date”?

(I ought some time update the old thread with my current procedure—which is much more automated and quicker.)

Stephen

1 Like

Hey @Stephen_C,

I have and sometimes uses Hazel, but I’m sure that, like DEVONthink, I severely under-use it.

No, I tried and it makes no difference if I choose any other placeholder like ‘Newest Document Date’.

Thank you so much for your time and help!

Charlie

OK - let’s try an updated version of the procedure. If this is too short or confusing in any way just post back here and I’ll try to explain more clearly later. I’m a little short of time just at the moment but I will later or tomorrow provide any help you need.

  1. Take a look at this link on the Hazel forums—which explains my Hazel rules involved the procedure of extracting entries from Day One. Note I deal with the renaming of the imported records in Hazel.
  2. The relevant DEVONthink smart rule (applied on import) looks like this:

2022-08-07_17-27-01

I move the imported entries to a Temp group simply to check and apply any of the scripts mentioned in the penultimate paragraph below.

The script include in ithe smart rule is as follows:

on performSmartRule(theRecords)
	tell application id "DNtp"
		try
			
			repeat with theRecord in theRecords
				-- first we remove the extension from the record name
				set theLongDateText to (name without extension of theRecord) as string
				-- now we simply populate the custom metadata with the date text
				add custom meta data theLongDateText for "diaryentrydate" to theRecord
				-- ensure we have a blank line before the metadata
				set theText to plain text of theRecord
				set amendedText to return & theText
				set plain text of theRecord to amendedText
			end repeat
			
		on error error_message number error_number
			if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		end try
	end tell
end performSmartRule

The only purpose of the script in that rule is to create custom metadata (available only in the Pro edition of DEVONthink) with a date in the format (e.g., Sunday 7 August 2022.md)—which allows sorting by date. (Of course, there are other ways of renaming the diary records so that they will sort automatically and correctly but I prefer to see dates—i.e., record names—in a format I recognise immediately.)

This all sounds very long-winded but once it’s set up it’s all very quick and efficient. In addition, I use other scripts to add the weekday name to the date at the start of the imported entry, to convert Day One links to DEVONthink item links (with a little manual work involved in Day One) and to convert hashtags (which is what I use in Day One to ensure tags carry over to DEVONthink, having set the relevant preference in DEVONthink) to YAML front matter.

I’m happy to help with anything you need but if it starts involving the Hazel rules maybe we should take it to direct messages here so we don’t get too far off topic in this thread.

Stephen

Some time over the next couple of days I’ll try to write down more fully not only my current import procedure when getting entries from Day One into DEVONthink but will also supplement that by bringing together in the same thread the various scripts I use to enhance the imported entries.

Stephen

So, your records are named Sunday,…, Monday,… etc? When you sort them, don’t you get all the Mondays first, then all the Fridays, Thursdays,…? Or I misunderstood you.

You are correct: each record is named in the format Sunday 7 August 2022.md. Somewhere on this forum we’ve briefly discussed this before and you did then intimate it was not particularly clever to do that. :grinning: You are, of course, correct. It would have been more sensible to use a more standard, sortable format, like 2022-08-07.md—so that records automatically sort properly within their year groups.

However, I now have just over 19,000 records with Hazel smart rules and a number of key scripts which depend upon that naming format so I’m not (currently) planning to change all of the record names. That explains why I use custom metadata to store the name of each record as a date—enabling quick sorting on the date.

There was originally another issue in that export from Day One did not include the name of the weekday at the start of each diary record. Being able to see that at a glance from the record name was thus important. However, I now use a script on import of the entries which adds the weekday to the date in the heading of the record so have shot myself in the foot with that particular argument.

Stephen

I see. And the meta data field is of type date, I guess. Apparently, DT automatically casts the string you use in adding the metadata to a date. I wasn’t aware of that and draw the wrong conclusion.

Yes.

Stephen

I wish formally to acknowledge that you have won. :grinning: The “proper” format for date named records is clearly 2022-08-07 (i.e., name sortable format) so this morning I wrote a script and have since been somewhat involved in renaming my 19,000 diary records in DEVONthink.

It is a tribute to the superb robustness of DEVONthink that (after I’d most carefully checked, in preferences, Update name of item links automatically) the many hundreds of links (effectively cross-references) within my diary records work perfectly notwithstanding the change of record names. :pray: :pray: :pray:

Now all that remains is for me to change all my other scripts that rely on the record names to reflect the new format. Thanks for the work!

Stephen

2 Likes

Wow. Congrats! I was actually thinking about mentioning the “right” format again but decided against it because I assumed it would be too much work to change the dependent scripts.

In the end, the process should be a lot easier, I believe.

1 Like

Hi @Stephen_C, I’m writing to let you know I’m so sorry I couldn’t answer you sooner, and I want to thank you for your detailed answer.

I had very busy days and couldn’t find a moment to work on this.

I will try the new method your shared tomorrow and answer again.

Thank you so much for taking the time to share it with us :blush:

Best regards,

Charlie

@charliecortial please don’t worry—there’s no hurry, take your time and just post back here if you have problems. Even if I can’t help you there are many here who will be happy and able to help.

Stephen

Hi everyone,

I’m sorry for taking so much time to answer, I had a few busy days recently and little time to spend on this, but I’m always impressed how powerful tools like DEVONthink (and Hazel) can be.

@Stephen_C kindly helped me understand how parts of the feature set of Hazel was working in private messages, and it’s quite impressive to see those tools working so well in tandem.

I also found this conversation between @chrillek and @Stephen_C about date formats to be quite interesting for choosing the right way to name things and avoid future difficulties when sorting files and folders.
I also tended to use a sortable format like YYYY-MM-DD over the years, so I mostly adapted the impressive rules and script that Stephen kindly shared with us.

Thanks to everyone that took the time to answer me, and I hope this thread can be useful to others!

1 Like

Is there a way for me to edit my first post?
I should change my title for it to better reflect the content of the thread.

Try clicking on the pen/pencil at the bottom of the post, Charlie. Thank you for the kind comments.

Stephen