Human help needed! Script to create a list of file names in a group into a new markdown file

Hi,
I am coding challenged - I know naff all about coding so decided to ask chatGPT to create a script to list the file names within a group in DT3. This is what it came up with on the 9th go:

tell application “DEVONthink 3”
set theGroup to (choose folder with prompt “Please select a group:”)
set theDatabase to database of theGroup
set theFiles to (get every file of theGroup)
set outputString to “”
repeat with aFile in theFiles
set outputString to outputString & "- " & (name of aFile) & “\n”
end repeat
set theNewDocument to (create document at end of documents of theDatabase with properties {text:outputString})
end tell

I keep getting this syntax error highlighting the word ‘document’ after the ‘(create’ on the second last line: Expected “,” but found class name.

I have no idea if this will work I just wanted to try it. I have tried to get chatGPT to correct the error and it keeps turning out new versions of the script all of which have the same error.

So humans - what is chatGPT doing wrong, is this script any use and how can I get a new document with a list of all the files in a particular folder/group in DT3?

Thank you!

Well, let’s face the reality - ChatGPT is an impressive solution but plain stupid. In the end it’s just reprocessing the data available on the web without any real understanding. Frequently the results are amazing (due to the huge amount of data & processing power) and in some cases like this one just nonsense. The above “script” is obviously based on various snippets and mixing them without knowing or understanding DEVONthink’s script syntax.

The most basic working script looks like this:

tell application id "DNtp" to return name of children of current group

But even humans need more input (and that’s what a true AI would have asked for), e.g. which group and what do you actually want to do with the names?

3 Likes

Hehe. Thank you human. So by ‘which group’ do you mean it’s name? If so its called “- OR M&S TOPICS” and I just need a file that is a list of all the file names in that group/folder

This example creates a plain text listing in the current group, you just have to change the value of the pGroupName property to the desired name.


property pGroupName : "TheNameOfTheGroup"

tell application id "DNtp"
	set theGroup to parent named pGroupName of current database
	set theNames to name of children of theGroup
	set AppleScript's text item delimiters to return
	create record with {name:pGroupName, type:text, content:theNames as string} in current group
end tell
1 Like

Wow - Thank you

I came just to say hi to a fellow Brit (and hum the Captain Scarlet theme song), and if I had any doubt you’ve lived in the UK you said “naff” in your post :joy:

Which I’m guessing chatGPT would have a little trouble parsing, I doubt it adapts well to non-American dialects (not convinced it would fare well with some American dialects actually).

1 Like

Well hello old bean,
Hmmm I think I may test chatGPT with some good British chat and see what happens.
Where are you from?