From f1a2256c85d914b5b4483427dcbc707fb17e17e0 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Sat, 22 Jun 2019 17:27:53 +0000 Subject: [PATCH] [zsh] add over-engeneered renumbering function --- home/.zshrc.local | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/home/.zshrc.local b/home/.zshrc.local index 1e6c472..bb5adb0 100644 --- a/home/.zshrc.local +++ b/home/.zshrc.local @@ -104,6 +104,20 @@ function urlencode() { python3 -c "import urllib.parse; print(urllib.parse.quote(open(0, 'rb').read()))" } +function renumber() ( + if (( $# < 2 )); then + echo "USAGE: $0 DIGITS FILES" + return 1 + fi + digits=$1 + shift 1 + i=1 + for file in $@; do + mv "$file" "$(dirname $file)/$(printf %0${digits}d $i).${file##*.}" + i=$((i+1)) + done +) + function mkvextract-all-attachments() { mkvextract $1 attachments $(mkvmerge --identify $1|grep "Attachment ID"|sed "s/Attachment ID \([0-9]*\): .*/\1/") }