eolas/scripts/tidy_filenames.sh

22 lines
462 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
2024-10-22 17:24:04 +01:00
continue
2024-04-14 18:45:38 +01:00
echo "No filename change needed"
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