如何在xcopy中将日期附加到目录路径 [英] How to append date to directory path in xcopy
本文介绍了如何在xcopy中将日期附加到目录路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在bat文件中确实有一个xcopy语句. 您能帮我将今天的日期附加到目的地中的目录之一吗? xcopy/S/E/I%sourceFolder%"C:\ Shared \ copy \%destinationFolder%"
I do have a xcopy statement in bat file.. would you please help me to append today's date to one of directories in destination xcopy /S /E /I %sourceFolder% "C:\Shared\copy\%destinationFolder%"
今天的日期是06072013,所以我希望目的地如下所示
today date is 06072013 so I want my destination look like below
C:\ Shared \ copy-today的日期........
C:\Shared\copy-today's date........
谢谢
推荐答案
这是获取不依赖于区域设置的日期戳的方法. Wmic在Windows XP Pro和更高版本中可用.
This is method of getting a date stamp that doesn't depend on the regional settings. Wmic is available in Windows XP Pro and higher.
@echo off
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a
set datestamp=%dt:~0,8%
set timestamp=%dt:~8,6%
set YYYY=%dt:~0,4%
set MM=%dt:~4,2%
set DD=%dt:~6,2%
set HH=%dt:~8,2%
set Min=%dt:~10,2%
set Sec=%dt:~12,2%
set stamp=%YYYY%-%MM%-%DD%
md "C:\Shared\copy-%stamp%"
xcopy here...
这篇关于如何在xcopy中将日期附加到目录路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文