批处理过程将具有YYYYMMDD格式的日期的文件从一个文件夹移动到另一个文件夹

时间:2012-01-20 07:12:48

标签: batch-file

我可以通过批处理过程中的命令MOVE来移动文件而不考虑日期。

move C:\DESTINATION\FILE.txt C:\DESTINATION\

但由于我的文件包含日期格式,我需要根据当前日期移动文件。

2 个答案:

答案 0 :(得分:1)

您可以使用wmic获取当前日期:

for /f "skip=1" %%x in ('wmic os get localdatetime') do if not defined MyDate set MyDate %x
set MyDate=%MyDate:~0,8%

然后移动它们:

move %MyDate%.txt destination

答案 1 :(得分:0)

移动“文件名%日期:~10.4 %%日期:~4,2 %%日期:~7,2%.txt”“C:\ Destination \ Folder \”

编辑:此格式适用于英语(美国)日期格式。它快速而坚韧= D

相关问题