Skip to content

Instantly share code, notes, and snippets.

@KingPin
Last active July 20, 2017 03:10
Show Gist options
  • Save KingPin/dfa1e84a21b85c657e53d04420f86273 to your computer and use it in GitHub Desktop.
Save KingPin/dfa1e84a21b85c657e53d04420f86273 to your computer and use it in GitHub Desktop.
remove 4 numbers from front and add to end of the file name, accounting for spaces, dashes, and adding the numbers in parentheses
find ./ -name '???? - *.xml' -print0 | while read -d ''; do
[[ $REPLY =~ (.*)/(....)\ -\ (.*)\.xml$ ]] || continue
path=${BASH_REMATCH[1]}
num=${BASH_REMATCH[2]}
str=${BASH_REMATCH[3]}
echo mv "$REPLY" "$path/$str ($num).xml"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment