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-04-03 05:47:50 +02:00
|
|
|
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
|
|
|
|
2022-04-03 06:43:18 +02:00
|
|
|
autoload -U die
|
|
|
|
|
|
|
|
[[ ${ARGC} -ne 1 ]] && die 1 "Usage: ${0} <directory>"
|
2022-03-19 04:34:14 +01:00
|
|
|
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
|