Created
September 17, 2019 22:13
-
-
Save espinz/ca565801aa40b673db400343449927f3 to your computer and use it in GitHub Desktop.
renaming directories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COUNT=$(ls | grep -E "Chapter\ [0-9]" | cut -d ' ' -f 3-10 | wc -l) | |
for x in `seq 0 $COUNT`; do | |
if [ "$x" -eq "0" ]; then | |
newDIRS=$(ls | grep -E "Chapter\ [0-9]" | cut -d ' ' -f 3-10 | head -n 1) | |
mkdir "$x. ${newDIRS}" | |
else | |
DIRS=$(ls | grep -E "Chapter\ [0-9]*" | sort -k2 -n | cut -d ' ' -f 3-10 | tail -n 15 | sed -n ${x}p) | |
newDIRS=$(ls | grep -E "Chapter\ [0-9]" | cut -d ' ' -f 3-10 | sed -n ${x}p) | |
mkdir "$x. ${DIRS}" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment