How to apply dos2unix recursively to all the contents of a folder?

find /path -type f -print0 | xargs -0 dos2unix --


Skipping binaries and hidden files were important for me:

This one worked well for me:

find . -type f -not -path '*/\.*' -exec grep -Il '.' {} \; | xargs -d '\n' -L 1 dos2unix -k

Which translates to: find all non-hidden files recursively in the current directory, then using grep, list all non-binary (-I) non-empty files, then pipe it into xargs (delimited by newlines) one file at a time to dos2unix and keep the original timestamp.

See also:

https://github.com/mdolidon/endlines


Using bash:

shopt -s globstar
dos2unix **

The globstar shell option in bash enables the use of the ** glob. This works just like * but matches across / in pathnames (hence matching names in subdirectories too). This would work in a directory containing a moderate number of files in its subdirectories (not many thousands).

In the zsh and yash shells (with set -o extended-glob in yash), you would do

dos2unix **/*