1
0
Fork 0

mksmol: Don't rename DIR, only files

This commit is contained in:
tastytea 2022-03-19 00:53:48 +01:00
parent cd9e60cb5b
commit 512682aa01
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
1 changed files with 4 additions and 2 deletions

View File

@ -53,16 +53,18 @@ function cat-highlight()
}
# Makes all files in DIR lower case. Works with Non-ASCII characters.
# Equivalent to `zmv "${dir}/(*)" '${dir}/${1:l}'`
function mksmol()
{
if [[ ${ARGC} -ne 1 ]]; then
echo "usage: ${0} DIR" >&2
return 1
fi
local dir="${1}"
for file in "${dir}"/*; do
newfile="${file:l}"
basename="${file##*/}"
newfile="${dir}/${basename:l}"
[[ "${file}" != "${newfile}" ]] && mv "${file}" "${newfile}" || :
done
}