bin/lispify

13 lines
399 B
Plaintext
Raw Normal View History

2023-08-11 18:48:18 +02:00
#!/usr/bin/env zsh
# Lispify - convert file names to-lisp-case
filename=$(basename -- "$1")
extension="${filename##*.}"
filename="${filename%.*}"
new_filename=$(echo ${filename// /-} | tr '_' '-' | tr -cd '[:alnum:]._-')
new_basename=$(echo "$new_filename.$extension")
mv -i "$1" "$new_basename"
if ! [ "$new_basename" = "${new_basename:l}" ]; then
mv -i "$new_basename" "${new_basename:l}"
fi