Batch file 如何将当前日期添加到批处理文件

Batch file 如何将当前日期添加到批处理文件,batch-file,Batch File,我想缩小javascript。所以我写了一个批处理文件。因此,在输出中,我希望该文件名包含当前日期。这是我的代码 ECHO OFF PATH=%PATH%;C:\Program Files\Microsoft\Microsoft Ajax Minifier set Date=%date ajaxmin PandaStream.js jquery-1.7.2.min.js jquery-ui-1.9.2.custom.min.js iscroll.js jquery.custom-scrollba

我想缩小javascript。所以我写了一个批处理文件。因此,在输出中,我希望该文件名包含当前日期。这是我的代码

ECHO OFF PATH=%PATH%;C:\Program Files\Microsoft\Microsoft Ajax Minifier set Date=%date ajaxmin PandaStream.js jquery-1.7.2.min.js jquery-ui-1.9.2.custom.min.js iscroll.js jquery.custom-scrollbar.js backstretch.min.js overlay.js jquery.hightlight.3.js jquery.dataTables.1.8.2.min.js jquery.poshytip.min.js timeentry.js JQuery.Cookie.js autoresize-1.04.js prettycheckboxes.js tiptip.js jquery.touchSwipe-1.2.5.js jquery.minicolors.min.js jeditable.js chosen.jquery.js jquery.imagesloaded.js JQuery.textareaCounter.plugin.js nicedit.js jquery.progressbar.min.js jquery.DefaultText.js jquery-animate-css-rotate-scale.js jquery.colorbox.js jquery.datepick.js jquery.Jcrop.js jquery-datatables-editable.js DeviceDetect.js jquery.cropzoom.js lb.js ../plupload/js/plupload.full.js ../plupload/js/jquery.plupload.queue/jquery.plupload.queue.js common.js hotkeys.js profilemenu.js cssdropdowns.js LB/timelineEventMedia.js vault.js Datevalidation.js Socialmedia.js GuidedTour.js Sharing.js AddFamilyMember.js Uploads.js events.js EventHtmlTemplates.js -out Mini/minScript.* %DEST%\*.js -clobber 

如果需要在批处理文件中使用当前日期,则变量
%date%
具有当前日期:

echo %date%
25/05/2013

将其设置为variable,然后创建文件

set currdate=%date:/=%
copy filename.txt file-%currdate%.txt


不,它不起作用。如果我这样写,那么它就不会创建那个文件。请检查我的代码…根据这一点,请给我一些建议。@user3095273:请接受对您有帮助的答案。现在我有另一个问题。我要用连字符分隔时间和日期。我尝试了%TIME:~3,2%,但它只返回分钟。但我需要小时、分钟和秒。
set backupFilename=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%