Skip to content

Instantly share code, notes, and snippets.

@kosztik kosztik/rename_accent
Last active Aug 31, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.