eolas/scripts/tidy_filenames.sh

21 lines
481 B
Bash
Raw Normal View History

#!/bin/bash
# Convert hypens in file names to underscores
main() {
2024-03-14 15:08:03 +00:00
find . -depth -name '*.md' | while read fname; do
new_fname=$(echo "$fname" | tr " -" "_")
2024-03-14 15:00:03 +00:00
if [ -e "$new_fname" ]; then
echo "File $new_fname already exists. Not replacing $fname"
else
echo "Creating new file $new_fname to replace $fname"
2024-03-14 15:00:03 +00:00
mv "$fname" "$new_fname"
fi
done
}
# Run and pipe errors and feedback to logfile
2024-02-26 17:32:51 +00:00
# &>/dev/null
main