first, i'm unsure if "automator" (see your launchpad) can do this for you - i've never used it. But if you can use automator i think you should prefer it. Also automator supports "Apple Script" which can do more than bash(1) can.
http://www.linuxquestions.org
the people in that forum will quickly answer your "bash shell" questions (Terminal opens a bash shell by default), i see people above have problems doing so
however let me warn you directory names matter. white spaces in the name means you need a script which properly handles spaces in names. it also matters if there are files in the (starting) directory, that your script processes only directories not files
Create this file below (using vi(1)*) and use "chmod +x file" to make it a script. Put it in "echo $PATH" so it can be found. Always run scripts like "sh file" not "./file" unless told not to. Insure your script name doesn't conflict with a system script name by using which(1). (run: man vi, vi has a manpage in section 1 which tells you how to use it)
#!/bin/sh
pwd="$PWD"
for x in *
do
[ -d "$x" ] || continue
cd "$x"
echo "$PWD"
cd "$pwd"
done
pwd= stores the name of the base directory in variable named pwd. $PWD is the value of the current directory (where you are). note the quote whenever $ is used anywhere, VERY IMPORTANT.
for do done forms a loop that continues for each item in the directory using * (you can use `find .` instead and find(1) options, in advanced situations this may matter)
[ -d "$x" ] || continue. this uses test(1) which has shorthand [] with -d to insure we're using cd(1) on dictories not files in the directory. it uses "short circuit logic" || (OR) which continues the loop with the next * if the item "$x" is not a directory (it may be a file or something else).
you already know cd(1)
echo(1) has a manpage and just shows we've changed to a subdirectory and it's name. you'd insert whichever commands you need in place of it.
# man bash
will give you full instructions on what more you can do
# ls /bin
# ls /usr/bin
will give you a list of commands you can use as a normal user in your bash script
bash is good for quick things but unless you know awk(1) you will be somewhat limited what you can accomplish
https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Con ceptual/MacAutomationScriptingGuide/Crea…
Apple script can active a wider choice of script languages and abilities and has a more user friendly way of doing it (and help pages to more easily browse too). It may be a better thing to learn than bash(1) for you. It even allows cocoa and making graphics via script. you may need to install "xcode" from app store to use apple script. it's free and from Apple.
(in the 1980's scripting in a several powerful languages, graphics and minimal desktop manipulation too could be done in unix using bash, X11/Motif, ps and more - though few did so or knew how 🙂, cocoa isn't really new stuff!)
there is something nice things about bash(1) and Terminal. it gets the job done. it's small. it's quick to use. many people use it. it works about the same on (freeBsd and ubuntu). if you use it rarely (your not a script developing employee and needing graphics), bash is "appropriate". there are certain /usr/bin /usr/sbin that just aren't in automator or shouldn't be attempted by automator scripting, meaning you still need a Terminal.
so i can't really say learning cocoa is what you need. it may not be.