From 1b97f04f73bd893eeb06d3a1eacaf3eeaaec3741 Mon Sep 17 00:00:00 2001 From: thomasabishop Date: Sat, 17 Feb 2024 12:17:25 +0000 Subject: [PATCH] chore: add hypen to underscrore script for filenames --- scripts/hyphen_to_underscore.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 scripts/hyphen_to_underscore.sh diff --git a/scripts/hyphen_to_underscore.sh b/scripts/hyphen_to_underscore.sh new file mode 100755 index 0000000..01feab2 --- /dev/null +++ b/scripts/hyphen_to_underscore.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Convert hypens in file names to underscores + +main() { + find . -depth -name '*-*' | while read fname; do + new_fname=$(echo $fname | tr "-" "_") + if [ -e $new_fname ]; then + echo "File $new_fname already exists. Not replacing $fname" + else + echo "Creating new file $new_fname to replace $fname" + mv "$fname" $new_fname + fi + done +} + +# Run and pipe errors and feedback to logfile + +&>/dev/null +main