batch file + convert LF to CR+LF

天涯浪子 提交于 2019-11-29 11:04:10

You can find one way on this Wikipedia page:

TYPE unix_file | FIND "" /V > dos_file

Remember that you can't redirect the output to the same file you're reading from. This applies to pretty much all systems and shells, so an additional rename is necessary.

The key here is that type knows how to read LF line endings and find will then convert them do CRLF. type alone won't do anything with the output (it's supposed to, because having a command that simply dumps the file contents messing with them isn't good :-)).

Building on the generally noted way of doing this using the type command, you can also convert all of the files (or whatever wildcard you may prefer) and dump them in a temp folder using the following:

md temp
for %a in (*.*) do type "%a" | find /v "" > temp\"%a"

If the general idea was to replace the originals then you can just move the files back out of the temporary location and delete the temp folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!