Generate Markdown file from filenames in a group?

I am using DEVONthink in a nonfiction/academic context. I use the filenames in my database as citation keys. I would like to be able to accelerate some outlining drudgery by collecting all the filenames in a given group and exporting those filenames into a markdown file. It would be nice if I can pull some other metadata into the md file, but it’s not necessary. Anyone know of a good way to do this? Any suggestions would be much appreciated.

Hard mode: Can I do this with smart rules? :smile:

I use the filenames in my database as citation keys.

In what way?

I would like to be able to accelerate some outlining drudgery by collecting all the filenames in a given group and exporting those filenames into a markdown file.

So you’re trying to generate a Markdown file with the names of documents in a given group?
And where would this Markdown file be stored, e.g., in the same group?

Hard mode: Can I do this with smart rules? :smile:

Why would you need a smart rule to do this?
Please clarify what you’re thinking. Thanks.

Thank you for the quick response.

In what way?

Well, I name files with a bibTeX-compatible citekey. They’re simple for secondary sources: authorName:YYYY, but for archival sources they’re more abstract, because they are named following the structure of the archive, like “collectionabbreviation:B1:F2” or copying the filing system used by the originator e.g. “ED128613”

So you’re trying to generate a Markdown file with the names of documents in a given group?

Yes, exactly. I am replicating relevant files into groups based on an outline I wrote. I would like to easily collect the filenames (as these are the citekeys) in bulk, so those can be incorporated into the outline for the next step of writing.

In database applications I am used to being able to generating reports about contents in CSV or similar. Something analogous is what I have in mind here.

And where would this Markdown file be stored, e.g., in the same group?

Yes, although if it is helpful to use another folder I will do that.

Why would you need a smart rule to do this?

Ah. All I am saying is I would prefer to not to write a script.

You’re welcome.

Ah. All I am saying is I would prefer to not to write a script.

What you’re proposing isn’t possible without scripting of some kind.

I’ll have a look at this in the morning as I’m in bed at the moment and should be asleep :sleeping: :slight_smile:

If I’ve understood what you want correctly, then getting the documents names into a new markdown document is easy – DT3 has a command to do it. Just highlight all the documents in the group and Tools > Create Table of Contents > as Markdown will create a new markdown document called Table of Contents with a numbered list of the selected documents in markdown link form:

After that it depends how you want to manipulate this into your desired form - e.g. change all the bullet numbers to #, and/or strip the links.

Unfortunately, DT3 isn’t particularly good at this sort of search and replace - wildcards only take you so far and it ignores (most?) punctuation.

So, this would be a good case to use an external editor – IA Writer for example would turn the numbered list into headings using menu commands.

Or if you’re comfortable with regular expressions, any competent text editor (Vim, Emacs, BBEdit and many others) would easily do the conversion and strip the links if required.

Not quite a one-step process but it’s easy enough and doesn’t need AppleScript.

3 Likes

Just a little reminder that colons in filenames are not a Good Idea™ on macOS. If you ever transfer them to another platform, the colons will probably be something else (as they already are on macOS, anyway).

2 Likes

Yes, this is perfect. Not exactly the format I want but having the DT identifier linked is better for referring back to the document as I develop the outline further. I brought it into a few different tools and will play around to see which is good for the next level of outlining.

@chrillek Thank you for the reminder! The colons were just for reading clarity in the post and are not in the actual filenames.

1 Like