Last active
July 8, 2021 09:57
-
-
Save Saafke/8166ead1984ae3e7239b0f8e51c1a619 to your computer and use it in GitHub Desktop.
Subtracts a number from filenames with a number in them (no leading zeros). For example: out321.png -> out300.png if NUMBER_TO_SUBTRACT=21
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
NUMBER_TO_SUBTRACT=217 | |
for file in `ls -1v out*`; do | |
echo $file | |
NUMBER=${file:3:-4} | |
NEW_NUMBER=$[NUMBER-NUMBER_TO_SUBTRACT] | |
NEW_FILE_NAME="out${NEW_NUMBER}.png" | |
echo $NEW_FILE_NAME | |
mv $file $NEW_FILE_NAME | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment