文件从 UNIX(LF) 批量改为 PC(CR+LF) ,编码格式保持源文件编码,CMD转换成功

如何把文件从 UNIX(LF) 批量改为 PC(CR+LF) ,编码格式保持源文件编码,通过电脑自带cmd 批量更改-1.0

chcp 65001 && FOR /F "tokens=*" %f IN ('dir /b D:\opt\output\DATA_FILE\20230531\*.DAT') DO type "D:\opt\output\DATA_FILE\20230531\%f" | more /p > "D:\opt\output\DATA_FILE\20230531\output\%f.tmp" & TYPE "D:\opt\output\DATA_FILE\20230531\output\%f.tmp" && MOVE /Y "D:\opt\output\DATA_FILE\20230531\output\%f.tmp" "D:\opt\output\DATA_FILE\20230531\output\%f"chcp 65001 && FOR /F "tokens=*" %f IN ('dir /b D:\opt\output\DATA_FILE\20230531\*.DAT') DO type "D:\opt\output\DATA_FILE\20230531\%f" | more /p > "D:\opt\output\DATA_FILE\20230531\output\%f.tmp" & TYPE "D:\opt\output\DATA_FILE\20230531\output\%f.tmp" && MOVE /Y "D:\opt\output\DATA_FILE\20230531\output\%f.tmp" "D:\opt\output\DATA_FILE\20230531\output\%f"

--注意说明
windows电脑上 打开cmd,直接执行命令 
--会显示输出文件乱码,这里忽略,只是编译过程

chcp 936   --源文件编码是 GBK
chcp 65001 --源文件编码是 UTF-8
D:\opt\output\DATA_FILE\20230531  --源文件路径 
D:\opt\output\DATA_FILE\20230531\output --新文件输出路径

1. 找到要转换的源文件路径,创建新文件输出的路经

--D:\opt\output\DATA_FILE\20230531  --源文件路径 

 

2. 复制代码,根据自己的实际路径修改代码 注意说明,根据自己的 实际情况修改,改代码只用于

 UNIX(LF) 批量改为 PC(CR+LF)  

chcp 65001 && FOR /F "tokens=*" %f IN ('dir /b D:\opt\output\DATA_FILE\20230531\*.DAT') DO type "D:\opt\output\DATA_FILE\20230531\%f" | more /p > "D:\opt\output\DATA_FILE\20230531\output\%f.tmp" & TYPE "D:\opt\output\DATA_FILE\20230531\output\%f.tmp" && MOVE /Y "D:\opt\output\DATA_FILE\20230531\output\%f.tmp" "D:\opt\output\DATA_FILE\20230531\output\%f"chcp 65001 && FOR /F "tokens=*" %f IN ('dir /b D:\opt\output\DATA_FILE\20230531\*.DAT') DO type "D:\opt\output\DATA_FILE\20230531\%f" | more /p > "D:\opt\output\DATA_FILE\20230531\output\%f.tmp" & TYPE "D:\opt\output\DATA_FILE\20230531\output\%f.tmp" && MOVE /Y "D:\opt\output\DATA_FILE\20230531\output\%f.tmp" "D:\opt\output\DATA_FILE\20230531\output\%f"

--注意说明
windows电脑上 打开cmd,直接执行命令 
--会显示输出文件乱码,这里忽略,只是编译过程

chcp 936   --源文件编码是 GBK
chcp 65001 --源文件编码是 UTF-8
D:\opt\output\DATA_FILE\20230531  --源文件路径 
D:\opt\output\DATA_FILE\20230531\output --新文件输出路径

--打开cmd ,直接执行命令,等待命令执行完成

 3.输出文件的结果 ,在新文件输出路径下查看

 --D:\opt\output\DATA_FILE\20230531\output --新文件输出路径

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值