Give items the name of the group they are in using Apple Script

I have several thousand groups with proper names e.g. “This is correctly named” , each containing a file with a garbage name e.g. “qlwjhlgkah29546524oi”, and a formatted note, typically with the same proper name as the group. This has arisen from importing thousands of old scans from Evernote.

I have looked at the various threads on Evernote import for clues, and have made some progress adapting one the Apple Scripts (I am a rank amateur at scripts before you comment :-))

This script sort works on a single selected group (testing on a single group before going large!)

BUT parent 1 returns the name of a tag attached to item, parent 2 gave me tags and the group name.
I am clearly doing something wrong.

How, please, do I give the group name the items ?

Thanks. Chris

Just found this underneath my post.

Watching with interest as I also got the impression that the script discussed removed the properly named .HTML file.

As you found out, a record may have multiple parent groups; and each tag is also a group
How about repeating through the parent list; skipping tags

I think I would need a line in the script to do that.

I’ll give it a go and see what I can sort. Thanks

You could try to use location group instead. Though I’m not sure how that really works. Also, I’m not quite clear about the meaning of

If you are really working on a single selected group (i.e. selecting the group, not the records inside it), why do you go up one level with set currentLocation to parent 1 of theRecord?

As an aside: It would be a lot more helpful to post a script as code like so
```
code goes here
```
instead of a screenshot. One could of course extract the image and run OCR on it, but that would really be pushing it a bit.

A smart rule is actually sufficient:

1 Like

Awesome! Thanks.

It’s easy when you know how isn’t it!

Location group worked thanks.

Working at individual group level only while testing.