Help with Python script for appending/linking "Groups"

I have this simple python script that is supposed to allow me to append/link a “Group” from one .blend file to my active one. The only problem is, I need it to only append/link the Groups that I specify as apposed to linking all the groups of the .blend file to my new one. No matter how many different groups I create, it seems to link all of them to the new file. Here is my current script… How should I modify it?

start with: blender -P

from Blender import *

for f in files:
groups = Library.LinkableGroups()
if ‘Group’ in groups:
groups= Library.Datablocks(‘Group’)
for g in groups:
Library.Load(g, ‘Group’, 0, 0)
print “added %s” % str(g)

Well, I haven’t done this yet… but it looks like Library.Datablocks(‘Group’) simply has all the groups in it.

So, what you’re doing is saying if there’s a linkable group called ‘Group’ in the “LinkableGroups”, which means there is a datablock with all groups in it… then everything in that block is loaded.

In stead you should check the name in your for g in groups: loop. Probably something like: if == ‘something’: between the for loop and the Library.Load.

I haven’t tested what you’re doing at all, but that looks like the logical step to me… check what your print says as well…