My idea is to put each single couple of files in the same folder or using a script to scan for those files inside a bigger folder with subfolders. The output folder name should be created starting from the first part of the filename. I'll run a task for fileA1 and fileA2 with the target output to folder /../fileA, than one task for fileB1 and fileB2 using the output folder /../fileB, etc etc.
1. Running a script to produce the input variables in the proper pairing is probably more difficult than reading names from a plain text file. The reason is simple: the first thing you have to do is produce usable input for the work task.
Without well-formed input data, the work task can't be developed, tested, or made to work. But before anyone can even start developing the work task's script or scripts, they first have to develop the script that produces the well-formed input data.
In short, you have a prerequisite script to develop first.
2. One of the Rules of Thumb in programming is, "Be specific". This also applies when asking questions about programming. So far, you've been vague about important aspects of the problem you're trying to solve.
A script to produce properly paired filenames as input variables will need to be specific about how it matches filenames to the pattern for an input filename. That is, some files found during the scan will NOT be acceptable inputs, and the script must ignore them. But the only way anyone can write that script is to know what pattern an acceptable filename matches. These are too vague:
fileA1 and fileA2 with the target output to folder /../fileA
fileB1 and fileB2 using the output folder /../fileB,
filename1CODE1CODE2
filename2CODE1CODE2
filename3CODE1CODE2
In the first two cases, it looks like the pattern to match is the exact word "file" followed by an uppercase letter, then a single digit. If that isn't the pattern, then you need to be specific.
The "output folder" isn't a valid pathname. The initial "/" means the root of the filesystem (i.e. the root folder of the startup drive). The ".." refers to the "parent folder", which is meaningless for the root of the filesystem. "fileB" appears to be the concatenation of the base word "file" (presumed to be invariant for all pairs), and the upper-case letter (invariant for a pair, but varies for different pairs).
It's possible you meant to write "../fileB", which would be the parent folder of (presumably) the folder where "fileB1" and "fileB2" reside. That's a guess on my part, because the description is too vague, and you didn't give any specific examples with complete pathnames.
Or maybe you didn't mean for the "/../" to indicate an actual parent folder at all, and instead you meant it as an ellipsis or placeholder string. I can't tell.
In the latter 3 cases, I can't tell what "CODE1CODE2" represent. Does each "CODEn" represent a single Unicode character? Is "CODE" a literal string "CODE" followed by a single digit? Is "CODE1" a multi-character substring, and "CODE2" a different substring? Are "CODE1" and "CODE2" multi-digit numbers?
Without more specific details about exactly what kind of name matching patterns are involved here, I don't see how this could be programmed. A program is a description of specific step-by-step actions to take that accomplish a goal. Being specific is essential.
3. The command that traverses directory hierarchies, matches name patterns, and performs actions is named 'find'. It has its own syntax for specifying what to do, distinct from shell syntax.
I suggest that you look at
the man page for the 'find' command, and try some things yourself. If you run into a problem, or have a specific question to ask, feel free to ask it. For example, if you tried a particular 'find' command-line and got unexpected results, then ask. If you do, please follow these Rules of Thumb:
1. Be specific.
2.
Post your code. Show the complete exact cmd-line you used; copy and paste it. Details matter.
3. Describe what you expected to happen.
4. Describe what actually happened, and show any actual output.
Things start to get harder for me to understand but I'll (try to) figure out. Probably I'll need to ask some help to some local geek / CLI guru
If you have someone to interact with locally, that's probably going to work out better in the long run. Be prepared to provide details to that person.