【发布时间】:2018-12-21 08:11:17
【问题描述】:
我正在使用 Get-ChildItem 来获取日期不等于当前日期/今天的所有 tomcat 日志文件。我想获取日期不在日期范围内的 tomcat 日志文件。例如最近 7 天的文件名不应列出。
tomcat 日志文件名示例:
catalina.2018-12-21.log
host-manager.2018-12-21.log
$date=Get-Date (get-date).addDays(-0) -UFormat "%Y-%m-%d"
$file=Get-ChildItem "C:\tomcat\logs" -exclude "*$date*"
foreach($files in $file)
{
Move-Item -Path $files -Destination "C:\expiredlogs"
}
[.....]Get all of the logs filename where date is not in the last 7 days range from "C:\expiredlogs"
有没有什么好的、有效的方法来检索7天前到现在不在范围内的所有文件名?
【问题讨论】:
标签: powershell