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