|
Replies:
13
-
Pages:
1
-
Last Post:
2 May 25, 11:28
Last Post By: davidekholm
|
Threads:
[
Previous
|
Next
]
|
|
Posts:
90
Registered:
27-Aug-2019
|
|
|
|
Search and display results from within the app
Posted:
30 Apr 25, 16:09
|
|
|
|
Is there a way to search across an entire album and display the results in the app window?
What I am trying to do is:
Display all photos whose filename begins with the same 4 characters and then assign keywords to just those photos.
|
|
|
Posts:
8,081
Registered:
31-Jan-2006
|
|
|
|
Re: Search and display results from within the app
Posted:
30 Apr 25, 16:12
in response to: ming666
|
|
|
|
(Thread moved - the skin doesn't control what the jAlbum Explore mode does.)
|
|
|
Posts:
3,841
Registered:
18-Oct-2002
|
|
|
|
Re: Search and display results from within the app
Posted:
30 Apr 25, 17:30
in response to: ming666
|
|
|
Here's a small script you can run in jAlbum's system console that achieves just that (Groovy mode): rootFolder.descendants.forEach(ao) -> {
if (ao.name.startsWith("_SC_")) {
ao.keywords = "foo,bar"
}
}
Just replace the name pattern SC with what you want and "foo,bar" with the keywords you want. Now those keywords will be applied to all matching objects of the project.
|
|
|
Posts:
1,462
Registered:
6-Sep-2005
|
|
|
|
Re: Search and display results from within the app
Posted:
1 May 25, 07:08
in response to: davidekholm
|
|
|
|
Is this an incremental change, or does it overwrite the existing keywords?
|
|
|
Posts:
90
Registered:
27-Aug-2019
|
|
|
|
Re: Search and display results from within the app
Posted:
1 May 25, 09:07
in response to: Laza
|
|
|
|
I can report that it overwrites
|
|
|
Posts:
90
Registered:
27-Aug-2019
|
|
|
|
Re: Search and display results from within the app
Posted:
1 May 25, 09:08
in response to: davidekholm
|
|
|
Here's a small script you can run in jAlbum's system console that achieves just that (Groovy mode): rootFolder.descendants.forEach(ao) -> {
if (ao.name.startsWith("_SC_")) {
ao.keywords = "foo,bar"
}
}
Just replace the name pattern SC with what you want and "foo,bar" with the keywords you >want. Now those keywords will be applied to all matching objects of the project.
Thank you. It works well.
Is there a way to make it incremental instead of overwriting?
|
|
|
Posts:
3,899
Registered:
4-Aug-2006
|
|
|
|
Re: Search and display results from within the app
Posted:
1 May 25, 12:03
in response to: ming666
|
|
|
You could use rootFolder.descendants.forEach(ao) -> {
if (ao.name.startsWith("_SC_")) {
keywords = ao.getKeywords()
keywords += ",foo,bar"
ao.setKeywords(keywords)
println(ao)
}
}
|
|
|
Posts:
8,081
Registered:
31-Jan-2006
|
|
|
|
Re: Search and display results from within the app
Posted:
1 May 25, 12:53
in response to: RobM
|
|
|
|
Just wondering if having a leading comma might cause problems. Would it be safer to check the existing keywords for emptiness, first? If it's empty, make it foo, bar. But if it's not empty, append ,foo,bar.
|
|
|
Posts:
3,899
Registered:
4-Aug-2006
|
|
|
|
Re: Search and display results from within the app
Posted:
1 May 25, 14:41
in response to: JeffTucker
|
|
|
Just wondering if having a leading comma might cause problems. Would it be safer to check the existing keywords for emptiness, first? If it's empty, make it foo, bar. But if it's not empty, append ,foo,bar.
Not tried it but I think a leading comma would be ignored, like it was an empty string.
Just in case:
rootFolder.descendants.forEach(ao) -> {
if(ao.name.startsWith("_SC_")) {
keywords = ao.getKeywords()
if(keywords == null | keywords.equals(""))
ao.setKeywords("fo,bar")
else
keywords += ",foo,bar"
ao.setKeywords(keywords)
println(ao)
}
}
|
|
|
Posts:
3,841
Registered:
18-Oct-2002
|
|
|
|
Re: Search and display results from within the app
Posted:
1 May 25, 15:24
in response to: RobM
|
|
|
Here's a modified version that simply ADDS the listed keywords:
rootFolder.descendants.forEach(ao) -> {
if (ao.name.startsWith("_SC_")) {
var kw = ao.keywordSet
kw.add("foo")
kw.add("bar")
ao.keywords = kw
}
}
|
|
|
Posts:
90
Registered:
27-Aug-2019
|
|
|
|
Re: Search and display results from within the app
Posted:
1 May 25, 15:26
in response to: davidekholm
|
|
|
|
|
|
Posts:
3,841
Registered:
18-Oct-2002
|
|
|
|
Re: Search and display results from within the app
Posted:
1 May 25, 15:31
in response to: davidekholm
|
|
|
It strikes me I once made a very flexible API that handles long running tasks with progress bars and the ability to undo everything as a group + it pops up a dialog when it's done = better feedback. Here's a modified version using that API: Work.on(rootFolder.descendants)
.titled("Add multiple keywords")
.filter(ao -> ao.name.startsWith("_SC_"))
.forEach(ao) -> {
var kw = ao.keywordSet
kw.add("foo")
kw.add("bar")
ao.keywords = kw
}.showResult()
You can modify this code to only apply to selected objects by replacing rootFolder.descendants by selectedObjects. To have it apply to all objects of the current folder, replace rootFolder.descendants with currentFolder.children.
Edited by: davidekholm on 2 May 2025, 11:27: Modified to use filter instead of an if-clause, as that creates a correct reporting on # of objects processed.
|
|
|
Posts:
90
Registered:
27-Aug-2019
|
|
|
|
Re: Search and display results from within the app
Posted:
1 May 25, 15:39
in response to: davidekholm
|
|
|
|
|
|
Posts:
3,841
Registered:
18-Oct-2002
|
|
|
|
Re: Search and display results from within the app
Posted:
2 May 25, 10:25
in response to: ming666
|
|
|
|
|
|
|
Legend
|
|
Forum admins
|
|
Helpful Answer
|
|
Correct Answer
|
|