2022-03-19 04:34:14 +01:00
|
|
|
#!/usr/bin/env zsh
|
2022-03-19 03:54:51 +01:00
|
|
|
# Makes all files in <directory> lower case. Works with Non-ASCII characters.
|
|
|
|
# Equivalent to `zmv "${dir}/(*)" '${dir}/${1:l}'`
|
|
|
|
|
2022-03-19 04:34:14 +01:00
|
|
|
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}"
|
2022-03-19 04:34:14 +01:00
|
|
|
[[ "${file}" != "${newfile}" ]] && mv "${file}" "${newfile}" || :
|
|
|
|
done
|