hi all
looking for a way (preferably scriptable so can be run multiple times) to get a simple list of all my folder names with no levels , similar to a tree -L 3 -d -I
command.
anyone know how to do so?
thanks so much in advance
Z
hi all
looking for a way (preferably scriptable so can be run multiple times) to get a simple list of all my folder names with no levels , similar to a tree -L 3 -d -I
command.
anyone know how to do so?
thanks so much in advance
Z
records
(those are the groups, including Trash and others you might not want)records
of every groupthx @chrillek !!
is that via the GUI or AppleScript?
mind sharing and example?
I want to end of with a simple text list that looks like this based on the actual folder names
0-19 life
11 food
11.01 cook
11.02 review
11.03 dishes
11.04 tips
12 finance
12.01 salary bgu
best
Z
This provides a listing separated by the main parent group in the root…
tell application id "DNtp"
tell current database
set groupList to {}
set allParents to (parents whose (location is "/") and (type is not smart group)) -- This processes the root parents
repeat with theParent in allParents
if (name of theParent) is not in {"Tags", "Trash"} then
copy (name of theParent & ":" & return) to end of groupList
my processParent(theParent, groupList)
copy return to end of groupList
end if
end repeat
create record with {name:(name & " Listing" as string), content:groupList as string, type:txt} in root
end tell
end tell
return groupList as string
on processParent(theParent, groupList)
tell application id "DNtp"
set theKids to (children of theParent whose (type is group))
if theKids is not {} then
repeat with theChild in theKids
copy (name of theChild & return) to end of groupList
my processParent(theChild, groupList)
end repeat
end if
end tell
end processParent
You’re welcome
May I ask what you want this for?
sure, I am creating a index for the https://johnnydecimal.com system im applying to organize my devonthink groups and files
Gotcha. Have fun
sorry one last question
I just noticed this changes to whatever DB im currently editing can one set a defined DB so whenever the script is run its always on the same DB?
thx so much!
Z
Just change the database you’re talking to in the beginning of the script. You can refer to it by its name.
thx @BLUEFROG !
that’s the first thing I did try to do but even when putting the DB name in quotes it dosent see to work properly
tell application id "DNtp"
tell "00-99 skm"
set groupList to {}
set allParents to (parents whose (location is "/") and (type is not smart group)) -- This processes the root parents
if allParents is {} then return
repeat with theParent in allParents
if (name of theParent) is not in {"Tags", "Trash"} then
copy (name of theParent & ":" & return) to end of groupList
my processParent(theParent, groupList)
copy return to end of groupList
end if
end repeat
create record with {name:(name & " Listing" as string), content:groupList as string, type:txt} in root
end tell
end tell
return groupList as string
on processParent(theParent, groupList)
tell application id "DNtp"
set theKids to (children of theParent whose (type is group))
if theKids is not {} then
repeat with theChild in theKids
copy (name of theChild & return) to end of groupList
my processParent(theChild, groupList)
end repeat
end if
end tell
end processParent
thx!
Z
It’s a database. Not just a name.
Your command
tell "00-99 skm"
translates to
set allParents to (parents whose location is "/") and (type is ...)
But what is the parents
property of a string? That simply doesn’t exist.
Now, look at the code @bluefrog posted:
tell current database
where current database
is not a string but a database.
Which tells you that you need to provide a database to this tell
command. And as @bluefrog hinted later:
Where “it” is the database. Now, if you use “tell database” in the search function of the forum, you might find examples. Don’t forget the quotes around the search string!
Thx both it worked!
Z
You’re welcome