Skip to main content
2 of 3
Changed the wildcard to match multiple digits instead of just one

The following script does what you want:

#!/bin/bash
counter=0
mkdir foldNew
for i in fold?/dirA/aa*; do
    counter=$((counter + 1))
    mv $i foldNew/aa$counter
done

It keeps count of how many folders it moved already, and it uses Bash's wildcard system to iterate over all the folders you want to move.

I tested it with the setup you described, and it did what you wanted, with the only exception that it moved them to aa1 through aa11, because dirA has five subdirectories, not four.