Automating a command to work across sequential folders

A member of Directory Opus staff created the following command for me when my attempts failed:

Copy PATTERN * AS "_Index_{sourcepath|..|nopath|noterm}_*" TO "{sourcepath|..}"

I added this as a button to my toolbar, and since then I’ve used it hundreds and hundreds of times on many projects that ranged from 30 folder up to 150 folders each. All the clicking was okay because it was not multiple hundreds all at once.

I’m now facing a project with close to 2000 folders. So I’ve been trying to figure out a more automated way to do this. But with no luck.

This is what I’m trying to automate, based on how I would do it manually.

  1. I would enter the first subfolder under the root of the file tree on want to work on.

  2. If there is already a file called “_index*.jpg” OR there are NO subfolders, I would skip directly to the next Level A folder. Otherwise, I would enter the first subfolder (I’ll call this “Level B), highlight the first jpg I encountered (regardless of where it fell in an alpha sort). Then I would run the command I posted above. I would then move directly to the next Level A folder.

  3. I would repeat step 2 until I ran out of Level A folders in that tree.

Note: In the steps above I didn’t check to see if there are non-index jpgs at Level A. This rarely happens, and odds are they are not representative of the photo set. That’s why the file I used must be from Level B.

You would need to use scripting for that kind of conditional logic and recursion.

It's definitely possible, but more complex than a one-line command could do. We can help with questions but (at least speaking for myself) can't write the whole script at the moment due to other work that needs finishing.

I'll look into the scripting, and no need for anyone to write if for me. When I think about 2000 it sounds like a lot, but I just plowed through 350 of them and it was not bad. So I think all I have to do is spread this out over a few days so I don't stress my hands.