18 lines
481 B
Bash
Executable File
18 lines
481 B
Bash
Executable File
#!/usr/bin/env zsh
|
|
# Makes all files in <directory> lower case. Works with Non-ASCII characters.
|
|
# Equivalent to `zmv "${dir}/(*)" '${dir}/${1:l}'`
|
|
|
|
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
|
|
|
if [[ ${ARGC} -ne 1 ]]; then
|
|
print -u 2 "Usage: ${0} <directory>"
|
|
return 1
|
|
fi
|
|
local dir="${1}"
|
|
|
|
for file in "${dir}"/*; do
|
|
local basename="${file##*/}"
|
|
local newfile="${dir}/${basename:l}"
|
|
[[ "${file}" != "${newfile}" ]] && mv "${file}" "${newfile}" || :
|
|
done
|