Skip to content

Instantly share code, notes, and snippets.

@LightningStalker
Created April 10, 2025 23:28
Show Gist options
  • Select an option

  • Save LightningStalker/93d5d14c530731aca2680c95d2b67a31 to your computer and use it in GitHub Desktop.

Select an option

Save LightningStalker/93d5d14c530731aca2680c95d2b67a31 to your computer and use it in GitHub Desktop.
Shell script that renames some numbered files
#!/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