[英]Windows batch file: move files older than X minutes to a different directory using UnixUtils find command
我找到了適用於Windows的unixutils,並嘗試使用find命令將30分鍾以上的文件移動到另一個目錄。
我已經嘗試了以下所有方法(在SourceDir和/或TargetDir的末尾也用\\進行了嘗試),但是我敢肯定是由於使用/來分隔目錄的unix和使用\\來分隔目錄的Windows導致的各種錯誤:
find C:\SourceDir -name * -mmin +30 -type f -exec "move {} C:\TargetDir" ;
find C:\SourceDir -name * -mmin +30 -type f -exec "move {} C:\TargetDir" +
find C:\SourceDir -name * -mmin +30 -type f -execdir "move {} C:\TargetDir" ;
find C:\SourceDir -name * -mmin +30 -type f -execdir "move {} C:\TargetDir" +
有人有這個工作嗎?
我也不受使用此實用程序的束縛-似乎很容易做到。 不過,作為計划作業的一部分,我確實必須通過命令行來執行此操作,並且非常希望不必安裝任何軟件。 但是,可以復制獨立的單個文件實用程序。
我相信我也可以使用Windows Powershell。
謝謝!
我找到了幫助Windows Powershell的人。 我以為我會在這里提供更新,以防日后對他人有所幫助。
以下Powershell命令執行相同的操作:
get-childitem -Path "C:\SourceDir" -recurse | where-object {$_.LastWriteTime -le (get-date).AddMinutes(-30)} | move-item -destination "C:\TargetDir" -force
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.