Wish for an easy script, I think ...

Started by sinus, December 08, 2017, 07:38:43 PM

Previous topic - Next topic

sinus

... but I am not able to do it. (at the moment I gave up scripting, to difficult for me, maybe I jump in later next year).

I am asking, if a script-crack could do this script. I think, it should not be hard to do, but maybe I am completely wrong.

I had such a script in the past (VB-script).

What it should do:

After I select one or more collapsed stacks

Then the script comes into play, after clicking it should:

1) Expand all collapsed stacks
2) Select all files in all stacks
3) Empty a given category (unassign all files) (e.g. "analysis"; this I could later change in the code of course)
4) Add all selected files to this now empty category
5) Collapse all files again
6) Jump into this category

The two steps in italic font is fine, but could be omitted, if it is too complicated.

This would be great, if someone could create such a script. If not, does not matter, I can do it "by hand" of course, only slower  ;)

Background:
I have a category to "analyse" some files (this would be the cat to empty and fill in the script, called here "5 Analyse", see attachement.)
This category has some subcategories, where I can see, what files are delivered, or all masters, all versions and so on.
Means, I select e.g. an event, add all files to this category and can then see very convenient, what files I have delivered to our clients or family and so on (sub-cats can be added easy).

Thanks in advance to think about this.







Best wishes from Switzerland! :-)
Markus

Jingo

Nice one... think I almost have this one written Markus.... stay tuned.. it may take me a day or so to make it all pretty!

Jingo

All set Markus - and no need to even unstack/restack the images!

Just download the zip file and unpack it to your apps folder: C:\ProgramData\photools.com\imatch6\webroot\user\Stack to a Cat

Right now - it is hardcoded to the analysis category.... but this can easily be changed on line 75 in the code.  Also, you can try to add code to let you choose from your existing Categories (load them in and add to a drop down) or even add a simple text box and then use that for the category.

Some additions that should be made:
  - create the category and assign if the category doesn't exist
  - aforementioned drop down selection of existing categories
  - some failure messages should be added in case of bad results
  - I believe this only works for a single (focused) stack.. so adding in multiple stacks should be the next enhancement!

Enjoy and good luck!!
 

sinus

Quote from: Jingo on December 09, 2017, 12:59:09 AM
All set Markus - and no need to even unstack/restack the images!

Just download the zip file and unpack it to your apps folder: C:\ProgramData\photools.com\imatch6\webroot\user\Stack to a Cat

Right now - it is hardcoded to the analysis category.... but this can easily be changed on line 75 in the code.  Also, you can try to add code to let you choose from your existing Categories (load them in and add to a drop down) or even add a simple text box and then use that for the category.

Some additions that should be made:
  - create the category and assign if the category doesn't exist
  - aforementioned drop down selection of existing categories
  - some failure messages should be added in case of bad results
  - I believe this only works for a single (focused) stack.. so adding in multiple stacks should be the next enhancement!

Enjoy and good luck!!


Hey Andy
How fast are you?! :o

Cool, sounds great! I am just now not at a Computer with Imatch, but I hope I am able to try your script as soon as possible.

I am curious, but if I read your text, it is exactly, what I need.

I will report here, as soon as I have tested it.

Thanks, Andy!!!  :D :D :D

Best wishes from Switzerland! :-)
Markus

Jingo

#4
My pleasure Markus... like I mentioned - it does need a bit of tweaking - but wanted to get something created for you while I had a moment (and the creative juices flowing)!  BTW: script was a modification of Mario's stack example app with a bit of finagle for the category add..  let me know how it works for you and we can tweak as time allows! - Andy.


sinus

Quote from: Jingo on December 09, 2017, 03:13:09 PM
My pleasure Markus... like I mentioned - it does need a bit of tweaking - but wanted to get something created for you while I had a moment (and the creative juices flowing)!  BTW: script was a modification of Mario's stack example app with a bit of finagle for the category add..  let me know how it works for you and we can tweak as time allows! - Andy.



Hi Andy,

I have tried it now, GREAT!
It works surely much faster, then I could do this "by hand".

Thanks a lot for this!!!

I am happy with this.
If I can imagine an enhancement, then this (I have no clue, if this is not possible or hard to do or easy ...

If the analysis-category is NOT empty, a box should ask "want you empty the cat before assigning the selected files, yes or no".

If this could be done, we could add several stacks, each after each.
Or, in contrary, if it is not empty, the script would empty the cat, because sometimes unassign files in this cat goes forgot.

If such a box is not possible, it would be great, that the script could empty the category before asssing the files.

This is the only enthancement, what I can imagine, and what would be very convenient.

If this is not possible, I am happy with the script, like you wrote and thanks again!

BTW: you have attached a nice icon, cool!
Best wishes from Switzerland! :-)
Markus

Jingo

Hi Markus - glad it is working out for you.. happy to write these apps when I have the time!

Here is an updated version that includes your wish list items... When you click the Assign Button, the app will now:
   
   1 - empty the 'analysis' category of all images
   2 - add the selected stack images into the 'analysis' category

You can rinse/repeat as many times as you need...  Enjoy!
 

sinus

Hey Andy

Thanks for your work, very appreciated.


Though here this new version works not more.
First it deleted the main - category and it appearad at anther place but with 0 files.

And because I had several sub-cats with formulas for the main-analyse-category, these formulas are gone.

But of course this I can quickly repair, I have only to create the formulas anew.

I do not know, why it works not now. I do the same like with the first version, and there it workes fine.
Also now the word "success" does not appear, with version 1 this word appeared.

No Problem, Andy, I will go back to the version one of you, this works very fine.
And only if you have time, maybe you can look into it, what is wrong.

Curious, that is works for you, but not here.

Thanks again for your effort!

(attached the cat with your category, but with 0 files in it)
Best wishes from Switzerland! :-)
Markus

Jingo

Hi Markus - hmmm... strange - it works for me here.

The category disappeared because I kinda cheated a bit... instead of trying to code it to clear all items from the category - I simply delete the category and recreate it again as a top level item.  Then, the system should add the focused stack back into it.  I didn't know you had deeper sub-cats off of it so this new code is not ideal for that.

If I get some time next week (won't happen this week) - I'll see about coding it more efficiently to only clear the items in the category thus leaving it where it is and not touching the sub-cats.

sinus

Thanks, Andy!

No hurry, do it only, if you have time and fun to do it!

You have already helped me with your first version, very good and very quickly!
Best wishes from Switzerland! :-)
Markus

thrinn

Andy,
from looking at the code (did not try to execute it):
The category is (re-)created in line 75, but the following statements to assign files to it run in parallel. They should be in the "then" part of the v1/categories/create.
Otherwise, v1/categories/assign might execute before the category has been created.
Thorsten
Win 10 / 64, IMatch 2018, IMA

Mario

Ye spotter of asynchronous whatchamacallits... ;)
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Jingo

Quote from: thrinn on December 11, 2017, 05:25:33 PM
Andy,
from looking at the code (did not try to execute it):
The category is (re-)created in line 75, but the following statements to assign files to it run in parallel. They should be in the "then" part of the v1/categories/create.
Otherwise, v1/categories/assign might execute before the category has been created.

Aha!  Funny - I must have removed that .then code while "cleaning up" the file for zipping... DOH!

Markus - give this version a try... thx Thorsten!

sinus

Quote from: Jingo on December 11, 2017, 08:15:08 PM
Quote from: thrinn on December 11, 2017, 05:25:33 PM
Andy,
from looking at the code (did not try to execute it):
The category is (re-)created in line 75, but the following statements to assign files to it run in parallel. They should be in the "then" part of the v1/categories/create.
Otherwise, v1/categories/assign might execute before the category has been created.

Aha!  Funny - I must have removed that .then code while "cleaning up" the file for zipping... DOH!

Markus - give this version a try... thx Thorsten!

Ah, yes, Andy, this time it works!
Funny, only a small chaninging and it works!  ;D

Cool, thanks a lot for this script!
Best wishes from Switzerland! :-)
Markus

Jingo

You bet Markus - as mentioned - lots of room for improvements.. and a fun starting point to further one's scripting skills!  Glad to help....