[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
拷贝文件后再循环监测最新的文件
? 拷贝后,怎么判断最新文件

TOP

回复 5# licunwei

新增的速度,最小间隔是多少?
试试4楼的

TOP

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

评分人数

TOP

返回列表