Help wRenaming Sorted files

Hello all,
I I wrote a shortcut to rename photos to give them a more descriptive name for work. Since Each photo has the same name, IOS adds a number after each. For example:
-Room H 1
-Room H 2
-Room H 3
Etc…
A different room would be named
-Room B 1
-Room B 2
-Room B 3
Etc…

Even though I take the photos in a specific order, and then SELECT the photos in the same, specific order, they are renamed in random order. So, the first photo should be named Room H 1, but it might be renamed to Room H 3.

The FILTER PHOTOs action (sorted by Time taken) doesn’t solve the problem. Using QUICK LOOK action, photos present in the correct order but when they are saved, the naming order is still random.

Anyone know what I’m doing wrong? Is there a specific piece of META data that I’m not considering that is overriding my intended order?

Here is the basic shortcut

Without having the actual shortcut to work with it is almost always a bit of guesswork. Screenshots simply never tell the whole story with shortcuts, and they don’t allow anyone to test with what you actually have.

As a result, my guess would be that while you are sorting the photos, your loop might be using the original unsorted photos rather than the sorted photos list.

If that is not the case, please post a link to the shortcut, so we can look at the details such as where magic variables are picked up from.

Thanks for reviewing. I figured that to be the case but I’ve moved the Filter action around and haven’t figured it out. Would appreciate your assessment.

Here is the link. Photo Master

@sylumer ’s assumption is correct. Your Repeat reference is pointing to your original Select photos actions, not the sorted list. Instead, select the output of the filter action as the list of photos to be used in the repeat action. — jay

Like this.

https://www.icloud.com/shortcuts/e54146a34af34a1e8601405e94b4a59b

Jaye, Stephen,

Thanks to both of you! Works like a charm now.

Out of curiosity, did you look in a specific location to check/verify that I had pulled the magic variable from the wrong place? Or did it just click because you’re so familiar?

Asking because I’d like to learn how to troubleshoot on my own. I must have spent 2 hours Saturday trying to figure this out and never got there.

One lesson learned for me will be to rename my variables when I create them so the variables are more obvious from the start. Hopefully that will help. Any other ideas/recommendations?

When I looked at the screenshot, I was taking an educated guess based on what was likely to have happened based on what I could see and what you described. I guess there’s a level of familiarity involved, but mostly it was analysing what you said and What I could see for the most likely cause.

Once I had access to the Shortcut, I could tap on the variable and select the option to reveal it’s source which confirmed it.

I have many; I’ve been using Shortcuts since it originally came out as Workflow. But they are probably all contextual to various approaches, or applicable to any programming.

In this case, just test as you build and break things down if they stop working. Both approaches should allow you to quickly identify the point of issue, and the option to duplicate your shortcuts means when breaking down, you can always work on a copy.

Similar response. Based on your description and my experience with Workflow/Shortcuts, I, too, assumed reference to the initial photos selection.

In addition to your good suggestion to rename variables for clarity and Sylumer’s comments, I would suggest judicious use of the Quick Look action to add in debugging. It can be a very helpful technique to analyze the output of individual actions. — jay