I want to browse the date wise folder in a script. The folders are created daily as per sys date like 20111221, 20111031
etc. My problem is I am not able to browse the folder from script, it is showing path error.
我想在脚本中浏览日期明智文件夹。这些文件夹是按照sys12日期每天创建的,如20111221,20111031等。我的问题是我无法从脚本浏览文件夹,它显示路径错误。
I am trying to browse D:\Sites\Sum\%DATE:~-4%%DATE:~4,2%%DATE:~7,2%\
我正在尝试浏览D:\ Sites \ Sum \%DATE:〜-4 %% DATE:~4,2 %% DATE:~7,2%\
Pls help
1 个解决方案
#1
0
Probably it is a problem with the date format. %DATE% returns the current date using the short date format, that is fully (endlessly) customizable. One user may configure its system to return Fri040811, and another user may choose 08/04/2011...it's a complete nightmare for a BAT programmer.
可能这是日期格式的问题。 %DATE%使用短日期格式返回当前日期,即完全(无限)可自定义。一个用户可以将其系统配置为返回Fri040811,而另一个用户可以选择08/04/2011 ......这对于BAT程序员来说是一个完整的噩梦。
A possible solution is to use WMIC. WMIC Path Win32_LocalTime Get Day,Hour,Minute,Month,Second,Year /Format:table
returns the date in a convenient way to directly parse it with a FOR.
一种可能的解决方案是使用WMIC。 WMIC路径Win32_LocalTime获取日,小时,分钟,月,秒,年/格式:表以方便的方式返回日期,以便用FOR直接解析它。
@ECHO OFF
FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') DO (
SET FD=%%F%%D%%A
)
ECHO D:\SITES\SUM\%FD%
#1
0
Probably it is a problem with the date format. %DATE% returns the current date using the short date format, that is fully (endlessly) customizable. One user may configure its system to return Fri040811, and another user may choose 08/04/2011...it's a complete nightmare for a BAT programmer.
可能这是日期格式的问题。 %DATE%使用短日期格式返回当前日期,即完全(无限)可自定义。一个用户可以将其系统配置为返回Fri040811,而另一个用户可以选择08/04/2011 ......这对于BAT程序员来说是一个完整的噩梦。
A possible solution is to use WMIC. WMIC Path Win32_LocalTime Get Day,Hour,Minute,Month,Second,Year /Format:table
returns the date in a convenient way to directly parse it with a FOR.
一种可能的解决方案是使用WMIC。 WMIC路径Win32_LocalTime获取日,小时,分钟,月,秒,年/格式:表以方便的方式返回日期,以便用FOR直接解析它。
@ECHO OFF
FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') DO (
SET FD=%%F%%D%%A
)
ECHO D:\SITES\SUM\%FD%