I'm going to throw this solution out there. Git will do this. See this post about it
So theoretically you could do this to convert an entire tree
cd root/of/tree
git init .
git add .
git commit -m "initial commit"
echo "* text eol=crlf" > .gitattributes
git rm --cached -r .
git reset --hard
Change crlf
to lf
if you want to go the other way. NOTE: you're not done yet, keep reading
Type git status
to see which files will be affected. You might have to add lines like
*.jpg binary
*.png binary
*.gif binary
etc to .gitattributes
to avoid converting certain files. You can also explicit mark certain files as text
*.md text
*.css text
Then just repeat these 2 lines after you've edited .gitattributes
git rm --cached -r .
git reset --hard
Then use git status
again to see which files will be changed. When you're sure all the files you want affected are listed by git status
then commit
git add .
git commit -m "normalize line endings"
now check all the files out again
git rm --cached -r .
git reset --hard
They should now have whatever your desired line endings are
** NOTE: If you were already using git skip the first 3 commands git commands. If you were not using git you can now delete the .gitattributes
file and the .git
folder.
** Back up your files: the git rm --cached -r
deletes them all (although they are theoretically in your git repo (the .git folder) which is how they get restored by the last command git reset --hard
. It's just since files are getting deleted it's probably best to back them up.