Skip to content

Instantly share code, notes, and snippets.

@EduardoThums
Created January 31, 2022 00:36
Show Gist options
  • Select an option

  • Save EduardoThums/ad05ee8aac5f951c7837cd3f4aaff22c to your computer and use it in GitHub Desktop.

Select an option

Save EduardoThums/ad05ee8aac5f951c7837cd3f4aaff22c to your computer and use it in GitHub Desktop.
Normalize MP4 files to a more human readable format.
#!/bin/bash
RENAME_FOR_REAL=$1
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for f in *.mp4
do
new_file=$(echo $f | grep --ignore-case -E 'ep-[0-9]*' -o | tr '[:upper:]' '[:lower:]')
echo "Renaming '$f' to '$new_file'"
if [[ -n $RENAME_FOR_REAL ]]; then
mv "$f" "$new_file.mp4"
fi
done
IFS=$SAVEIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment