mirror of
https://codeberg.org/hyperreal/bin
synced 2024-11-25 10:23:42 +01:00
To ChatGPT: modify this to include converting >=1 spaces to single dash
This commit is contained in:
parent
e79bedc940
commit
b0535faf49
8
lispify
8
lispify
@ -1,16 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This script was written entirely by ChatGPT 4.
|
||||
|
||||
# Check for an argument
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: $0 filename"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# A function to convert a string to Lisp case
|
||||
# A function to convert a string to Lisp case, including converting spaces to a single dash
|
||||
to_lisp_case() {
|
||||
echo "$1" | awk '{ gsub(/_/,"-"); print tolower($0) }' | sed 's/[A-Z]/-\L&/g' | sed 's/^-//'
|
||||
echo "$1" | awk '{ gsub(/[ _]+/, "-"); print tolower($0) }' | sed 's/[A-Z]/-\L&/g' | sed 's/^-//'
|
||||
}
|
||||
|
||||
# The filename is the first argument
|
||||
@ -30,5 +28,5 @@ if [ "$file" != "$new_name" ]; then
|
||||
mv -- "$file" "$new_name"
|
||||
echo "File renamed to $new_name"
|
||||
else
|
||||
echo "File name is already in Lisp case."
|
||||
echo "File name is already in the desired format."
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user