Created
April 10, 2025 23:28
-
-
Save LightningStalker/93d5d14c530731aca2680c95d2b67a31 to your computer and use it in GitHub Desktop.
Shell script that renames some numbered files
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
| #!/bin/bash | |
| ls mpv-shot*.jpg > b | |
| YEAR=$(date +%Y) | |
| COUNT=$(wc -l < b) | |
| FIRST=$((`ls Pictures/$YEAR/mpv-shot*.jpg | wc -l` + 1)) | |
| LAST=$(($FIRST + $COUNT - 1)) | |
| seq -f %04.0f $FIRST $LAST | | |
| paste b - | | |
| awk -F\\t '{ print $1, "Pictures/'$YEAR'/mpv-shot"$2".jpg" }' | | |
| xargs -n2 mv -i | |
| rm b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment