diff options
Diffstat (limited to 'functions/renlow.fish')
| -rw-r--r-- | functions/renlow.fish | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/functions/renlow.fish b/functions/renlow.fish new file mode 100644 index 0000000..98b0e4c --- /dev/null +++ b/functions/renlow.fish @@ -0,0 +1,21 @@ +function renlow --description 'Rename all files and directories with lowercase characters' + +if not command -sq 'find' + echo "Can't find find." + return 1 +end + +for file in (find . -type f) + set -l element (string split -r -m1 / $file) + mv $file $element[1]/(string lower $element[2]) +end + +set -f dirs (find . -type d) +for dir in $dirs[-1..1] # Rename directories in reverse order + set -l element (string split -r -m1 / $dir) + if not test -z $element[2] # Catch . + mv $dir $element[1]/(string lower $element[2]) + end +end + +end |
