本帖最后由 newswan 于 2024-6-26 09:00 编辑
- $pathSour = "D:\1\"
- $pathDest = "D:\2\"
- $timeInter = 1
-
- $filexmlLast = ""
-
- while ($True) {
- $filexml = Get-ChildItem -Path $pathSour -Filter "*603.xml" | Sort-Object LastWriteTime | Select-Object -Last 1
- $filexml = $filexml.FullName
- if ( $filexmlLast -ne $filexml ) {
- $filexmlLast = $filexml
- [xml]$xml = Get-Content -Path $filexml -Encoding "UTF8"
- $xml.datas.data.attribute | ForEach-Object {
- if ( $_.name -eq "msg" ) { $string = $_.value }
- }
- if ( $string -match '"CardLocalFee":"0","CardLocalPayfee":"0"' ) {
- $path = $pathDest + (Get-Date).ToString("yyyy-MM-dd") + "\"
- if ( -not ( Test-Path $path ) ) { New-Item -Type Directory -Path $path }
- Write-Host "Copy : $filexml"
- Copy-Item -Path $filexml -Destination $path
- }
- }
- Start-Sleep -Seconds $timeInter
- }
复制代码 1秒左右?如果生成时间间隔小于 $timeInter,会拷贝不全
时间间隔过小,会不会浪费性能? |