Created
August 31, 2015 15:51
-
-
Save innermond/8b2b6a4fec1b124510e3 to your computer and use it in GitHub Desktop.
It renames files from directories as last directory + increasing number on every folder the index is reset
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
| #/usr/bin/bash | |
| path= | |
| i=0 | |
| prevname= | |
| for file in */*/*/*.jpg; do | |
| path="${file%/*}" | |
| name=`basename "$path"` | |
| if [ "$name" == "$prevname" ]; then | |
| i=`expr $i + 1` | |
| else | |
| i=1 | |
| prevname="$name" | |
| fi | |
| mv "$file" "$path"/"$name $i" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment