Created
November 24, 2019 08:54
-
-
Save Mehanik/6bed1209172ff5edebfc839e8a5acb1a to your computer and use it in GitHub Desktop.
Rename multiple files with some increment
This file contains 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/env bash | |
FILES=$1 | |
export INCREMENT=$2 | |
for f in $(ls $FILES); | |
do | |
NEW_NAME=$(echo $f | sed -r 's/([^0-9]*)0*([0-9]*)(.*)/echo "\1$((\2 + $INCREMENT))\3"/ge') | |
echo "mv $f $NEW_NAME" | |
mv $f $NEW_NAME | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment