Board logo

标题: [日期时间] 【已解决】linux命令在bat中无法正确打印时间 [打印本页]

作者: shootman2    时间: 2020-8-11 10:12     标题: 【已解决】linux命令在bat中无法正确打印时间

本帖最后由 shootman2 于 2020-8-16 08:19 编辑

date1为linux下date命令,加1是与windows本地的date加以区别

如下命令,在cmd中执行可以正常显示
date1 "+%Y年第%V周"

而在bat中则打印为空
for /f "delims=" %%x in ('date1 "+%Y年第%V周"') do echo %%x
作者: Batcher    时间: 2020-8-11 10:30

回复 1# shootman2


bat脚本里面改成这样试试:
for /f "delims=" %%x in ('date1 "+%%Y年第%%V周"') do echo %%x
作者: shootman2    时间: 2020-8-11 19:57

回复 2# Batcher


    这个我试过了,不行的。
作者: Batcher    时间: 2020-8-11 20:01

回复 3# shootman2


试过这样吗:
for /f "delims=" %%x in ('date1 "^+%%Y年第%%V周"') do echo %%x

如果还是不行,请把报错信息发出来看看。
作者: shootman2    时间: 2020-8-11 20:18

本帖最后由 shootman2 于 2020-8-11 20:19 编辑

回复 4# Batcher


    还是不行,没有任何报错!

    系统是win10 1909
作者: Batcher    时间: 2020-8-11 21:19

回复 5# shootman2


参考 Q-01 的方法把代码执行过程发出来看看
https://mp.weixin.qq.com/s/6lbb97qUOs1sTyKJfN0ZEQ
作者: shootman2    时间: 2020-8-12 09:33

本帖最后由 shootman2 于 2020-8-12 09:38 编辑

回复 6# Batcher


    @echo off&setlocal enabledelayedexpansion

     for /f "delims=" %%x in ('date1 "^+%%Y年第%%V周"') do echo %%x
     
     pause
作者: shootman2    时间: 2020-8-14 11:48

继续求助大神。。。
作者: zaqmlp    时间: 2020-8-14 12:47

大概率是编码问题
作者: shootman2    时间: 2020-8-16 08:19

回复 9# zaqmlp


    感谢大神,还真是编码的问题。。。




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2