Skip to content

Instantly share code, notes, and snippets.

@kosztik
Last active August 31, 2019 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kosztik/e8cfe9015e01466d945d6eadb5458220 to your computer and use it in GitHub Desktop.
Save kosztik/e8cfe9015e01466d945d6eadb5458220 to your computer and use it in GitHub Desktop.
rename accent files and dirs
#!/bin/bash
PATH="/home/ebfijjk/anks"
# Put the old filenames in a file.
ls $PATH >> oldValues
# Put the new names without accents in another file
cat oldValues | sed -e 'y/āáǎàēéěèīíǐìōóǒòūúǔùǖǘǚǜĀÁǍÀĒÉĚÈĪÍǏÌŌÓǑÒŪÚǓÙǕǗǙǛ/aaaaeeeeiiiioooouuuuüüüüAAAAEEEEIIIIOOOOUUUUÜÜÜÜ/' >> newValues
# Create a new file with Old names and New names seperated by a #.
paste -d'#' oldValues newValues >> oldAndNew
# Read the file with both old and new names and rename them with the new names.
while IFS='#'; read oldValue newValue
do
mv "$oldValue" "$newValue"
done < oldAndNew
rm oldValues newValues oldandNew
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment