How do I write a bash script that goes through each directory inside a parent_directory and executes a command in each directory
I don't get the point with the formating of the file, since you only want to iterate through folders... Are you looking for something like this?
cd parent find . -type d | while read d; do ls $d/ done