Skip to content

Instantly share code, notes, and snippets.

@monadplus
Created September 11, 2024 18:11
Show Gist options
  • Save monadplus/73d87dc021346aac9a2ddc211a2055f4 to your computer and use it in GitHub Desktop.
Save monadplus/73d87dc021346aac9a2ddc211a2055f4 to your computer and use it in GitHub Desktop.
Rename files using a pattern
#!/bin/sh
for f in *mkv; do
source="$f"
target=$(echo "$f" | sed -r 's/Modern Family S([[:digit:]]+)E([[:digit:]]+)[^.]*.mkv/Modern Family S\1E\2.mkv/')
echo "$source => $target"
mv "$source" "$target"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment