dotfiles/.config/zsh/functions/mksmol

17 lines
467 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
autoload -U die
[[ ${ARGC} -ne 1 ]] && die 1 "Usage: ${0} <directory>"
local dir="${1}"
for file in "${dir}"/*; do
local basename="${file##*/}"
local newfile="${dir}/${basename:l}"
[[ "${file}" != "${newfile}" ]] && mv "${file}" "${newfile}" || :
done