Skip to content

Instantly share code, notes, and snippets.

@santerref
Forked from ronanguilloux/slugify.sh
Created June 1, 2017 19:43
Show Gist options
  • Save santerref/8b63b4fce0d6a73bc933482885d6b04a to your computer and use it in GitHub Desktop.
Save santerref/8b63b4fce0d6a73bc933482885d6b04a to your computer and use it in GitHub Desktop.
batch in bash to replace accents in filenames
#! /bin/bash
#
# slugify.sh by Ronan
#
# Distributed under terms of the MIT license.
#
for file in *.mp4; do
filename=${file%.*}
file_clean=`echo $filename | iconv -c -f utf8 -t ascii//TRANSLIT | sed -e "s/'//g" | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z`
final="$file_clean.mp4"
mv "$file" "$final"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment