dotfiles/.config/zsh/functions/mksmol

16 lines
433 B
Plaintext
Raw Normal View History

#!/usr/bin/env zsh
# Makes all files in <directory> lower case. Works with Non-ASCII characters.
# Equivalent to `zmv "${dir}/(*)" '${dir}/${1:l}'`
if [[ ${ARGC} -ne 1 ]]; then
print -u 2 "Usage: ${0} <directory>" >&2
return 1
fi
local dir="${1}"
for file in "${dir}"/*; do
2022-03-19 04:38:23 +01:00
local basename="${file##*/}"
local newfile="${dir}/${basename:l}"
[[ "${file}" != "${newfile}" ]] && mv "${file}" "${newfile}" || :
done