|
$workbasepath = "D:\jenkins1.65\workspace\CI_KKEnterprise(企业端)\EnterpriseCenterPublish"
cd $workbasepath
#获取最后发布时间
if (Test-Path lastPublish.txt) {
$lastUpdateTime = Get-Content .\lastPublish.txt
#转化为DateTime类型
$lastUpdateTime = Get-Date $lastUpdateTime[1]
}
else{
$lastUpdateTime = Get-Date 1/1/1997
}
#更新本次发布时间文件
Get-Date > lastPublish.txt
$filePath = "D:\jenkins1.65\workspace\CI_KKEnterprise(企业端)\EnterpriseCenterPublish"
$allFile = Get-ChildItem $filePath -recurse | ?{$_.PsIsContainer -eq $false}
foreach($file in $allFile)
{
$daySpan = ($file.LastWriteTime)
#if文件的最后修改时间 大于 最后一次更新时间的保留 其它的删除
if ($daySpan -ge $lastUpdateTime)
{
$file.FullName,$daySpan ,"$$$$", $lastUpdateTime
}else{
$file.FullName,$daySpan, "####" ,$lastUpdateTime
Remove-Item $file.FullName -Recurse -Force
}
} |
|
|