Skip to content

Instantly share code, notes, and snippets.

@niladam
Forked from ronanguilloux/slugify.sh
Created June 24, 2017 20:05
Show Gist options
  • Save niladam/71e91c531c7f3b0a19a7ec7652e74620 to your computer and use it in GitHub Desktop.
Save niladam/71e91c531c7f3b0a19a7ec7652e74620 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.
#
cd photos
for file in *.png; do
filename=${file%.*}
#file_clean=`echo $filename | tr -cs "[:alnum:]_" _ `
#file_clean=`echo $filename | iconv -c -f utf8 -t ascii`
#file_clean=`echo $filename | iconv -f utf8 -t ascii//TRANSLIT | iconv -c -f utf8 -t ascii`
file_clean=`echo $filename | iconv -f utf8 -t ascii//TRANSLIT`
final="$file_clean.png"
echo "mv \"$file\" \"$final\" "
done
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment