bin: refactor lowercase script

This commit is contained in:
xeruf 2023-09-22 06:21:13 +02:00
parent 905b43b5d4
commit bac21d5b60
2 changed files with 7 additions and 1 deletions

View File

@ -2,4 +2,5 @@
# Lowercase given files
#perl-rename 'y/A-Z /a-z-/' "$@"
#$(which perl-rename || echo rename) -iv 'y/A-Z /a-z-/' "$@"
find "$@" -exec sh -c 'mv -iv "{}" "$(echo "{}" | tr "A-Z " "a-z-" | sed "s|---|_|;s|\.-|.|")" 2>/dev/null' \;
sedrename "s| |-|;s|---|_|;s|\.-|.|;s|.*|\L\0|g" "$@"
# find "$@" -exec sh -c 'mv -iv "{}" "$(echo "{}" | tr "A-Z " "a-z-" | sed "s|---|_|;s|\.-|.|")" 2>/dev/null' \;

5
.local/bin/scripts/sedrename Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh -x
# Rename files according to a given extended regex sed expression
sedexpr="$1"
shift
find "$@" -exec sh -c 'mv -iv "{}" "$(echo "{}" | sed -E "'$sedexpr'")" 2>/dev/null' \;