English 中文(简体)
如何根据目前的日期复制档案和操作文字?
原标题:How to copy file and run script based on current date?

在午夜之后,我每天必须从前一天复制记录。

Log names are in format exYYMMDD.log. So today (22.10.2011) I would have to copy file named ex111021.log into some directory.

是否有可能用批量书写? 如果我不能够使用权力,但宁愿不在我的服务器上安装。

Edit: With help of Siva Charan I created this (polish win7 - echo %date% prints YYYY-MM-DD)

set /a yest_Day = %date:~8,2%-%var:~-2,1%
copy ex%date:~2,2%%date:~5,2%%yest_Day%.log targetDir
最佳回答

In powerhell :

$YesterdayfileName = [string]::format("{0:yyMMdd}", ((Get-Date).adddays(-1)))+".log
# today 22/20/2011 gives 111021.log

Copy-Item $YesterdayfileName c:	emp
问题回答

在<>Batch档案中采用这一方式。

Syntax of Copy Command:

copy sourcefilepath destinationfilepath

Example:

<><><>>今天>:>

copy ex%date:~12,10%%date:~4,2%%date:~7,2%.log D:

For yesterday s date:

set /a yest_Day = %date:~7,2%-%var:~-2,1%
copy ex%date:~12,10%%date:~4,2%%yest_Day%.log D:

您必须在档案名称ex111022.log//ex111021.log和目的地之前提供适当的档案途径。

你可以安排这一批次档案,每天进行。





相关问题
complex batch replacement linux

I m trying to do some batch replacement for/with a fairly complex pattern So far I find the pattern as: find ( -name *.php -o -name *.html ) -exec grep -i -n hello {} + The string I want ...

How to split a string by spaces in a Windows batch file?

Suppose I have a string "AAA BBB CCC DDD EEE FFF". How can I split the string and retrieve the nth substring, in a batch file? The equivalent in C# would be "AAA BBB CCC DDD EEE FFF".Split()[n]

How to check which Operating System?

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....