Here's the current structure of my directory.
.
├── Show 1
│ ├── Season 1
│ └── Season 2
├── Show 2
├── Season 1
└── Season 2
I want to rename the Season folders to include the name of the Show. The desired structure looks like this :
.
├── Show 1
│ ├── Show 1 - Season 1
│ └── Show 1 - Season 2
├── Show 2
├── Show 2 - Season 1
└── Show 2 - Season 2
Here's the script I wrote :
# Parse through all show folders.
for show in /Users/sanjeetsuhag/Desktop/* ; do
# Check if it is a folder.
if [ -d "$show" ]; then
# Parse through all season folders.
for season in $show/* ; do
# Check if it is a folder.
if [ -d "$season" ]; then
mv $season "$show/$(basename "$show") - $(basename "$season")"
fi
done
fi
done
This is my first time scripting in Bash. Is there any thing I could improve ?
*
expansion on yourfor
lines will cause problems if you have a space in a file name or directory since the shell splits things on whitespace. \$\endgroup\$ – chicks Jan 1 '17 at 15:34