I have updated the script in this posting
The features of the first posting were: create a subgroup of the current group, first prompting for a name of that subgroup (optionally appending the new name to the name of the parent).
The new version does the same thing if the thing selected is a group. If the selection is not a group, but one or more document records, then the script will create a subgroup in the parent and move those selected records to the new subgroup. The script will propose that the new group have the name of the first document – which can be overridden in the dialog.
This is idiosyncratic for my personal use cases and combines several actions I do frequently to organize project documentation. That’s why I did not include the proposed changes from @johseb in the post mentioned about. (Sorry about that, @johseb). I’m posting this because others might have use for the same procedure. I find this script very useful when I’m rearranging indexed files – first moving the documents into the database, rearranging them into subfolders, and then moving them back out to the parent of the index – the script doesn’t do the move into/move external actions but it does the stuff in the middle.
(*
see: http://forum.devontechnologies.com/posting.php?mode=reply&f=4&t=16841
makes a child group of the currently selected group
(a group must be selected, else the script fails)
20130704 modified to create a new group with the proposed name
as a subgroup of the current parent
set to the first item in a selection (name can be overwritten),
then create a group with that name (or other specfied in the dialog),
then move the selection to that new group
*)
property nameSep : ": "
tell application id "com.devon-technologies.thinkpro2"
set theSelection to (the first item of (the selection as list))
set theMoveSet to the selection
set currentGroup to current group
if the kind of theSelection is "group" then
set {nameOption, groupName} to {button returned, text returned} of (display dialog "Make group: enter group name" default answer "<name>" buttons {"Append to parent name", "Do not append to parent name", "Cancel"} default button 2 with title "Enter group name")
if nameOption is "Append to parent name" then
set groupName to (the name of currentGroup) & nameSep & groupName
end if
create record with {type:group, name:groupName} in currentGroup
else
set groupName to the name of (the first item of (the selection as list))
set {nameOption, groupName} to {button returned, text returned} of (display dialog "Move seleciton into New Group: enter group name" default answer groupName buttons {"Append to parent name", "Do not append to parent name", "Cancel"} default button 2 with title "Enter group name")
if nameOption is "Append to parent name" then
set groupName to (the name of currentGroup) & nameSep & groupName
end if
set theNewGroup to create record with {type:group, name:groupName} in currentGroup
repeat with thisItem in theMoveSet
set theResult to move record thisItem to theNewGroup
end repeat
end if
end tell