How do I remove carriage returns from directory names?

Linux's rename command makes this easy:

rename $'\r' '' *

This replaces the first and only carriage return ($'\r') by an empty string ('') in all file names in the current directory. Names that don't contain a carriage return are left unchanged (or you can write rename $'\r' '' *$'\r' to only consider files that must be renamed).

If you need to act on files in subdirectories as well:

shopt -s globstar
rename $'\r' '' **/*$'\r'

(Users of Debian, Ubuntu and derivatives: change rename to rename.ul, or change rename $'\r' '' to rename 's/\r//'.)

Alternative, using zsh's zmv function:

zmv $'**/*\r' "${f%?}"

EDITED: forgot to double escape the \r in the sed line

either of these should work for you

for i in $(find . -type d -name '*\r'); do mv "$i" "$(echo $i | sed -e 's/\\r//g')"; done

find . -type d -name '*\r' -exec mv "{}" "$(echo {} | sed -e 's/\\r//g')" \;

this will find all directories named *$\r under your currently directory

it will then mv(rename) them to the same name minus the \r