Skip to content

Instantly share code, notes, and snippets.

@rashivkp
Last active August 29, 2015 14:07
Show Gist options
  • Save rashivkp/cf84beb15f9229944c21 to your computer and use it in GitHub Desktop.
Save rashivkp/cf84beb15f9229944c21 to your computer and use it in GitHub Desktop.
rename files based on parent directory
#!/bin/bash
# change docRoot
docRoot=~/src/shakir/
for semester in */;
do
semester="${semester%?}"
cd "$docRoot/$semester/"
for branch in */;
do
branch="${branch%?}"
cd "$docRoot/$semester/$branch/"
for subject in */;
do
subject="${subject%?}"
cd "$docRoot/$semester/$branch/$subject"
for examdate in */;
do
examdate="${examdate%?}"
cd "$docRoot/$semester/$branch/$subject/$examdate"
mv 2.pdf "$semester$branch$subject$examdate.pdf"
ls
done
done
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment