簡體   English   中英

PowerShell - 按修改日期刪除特定文件夾中的文件

[英]PowerShell - Delete files by modified date in specific folders

閱讀源代碼不起作用,或者我什至不確定一切是否正常......需要你們的幫助。

謝謝!

$Src = C:\Users\Asus\Documents\PowerShell\Folder.txt

Get-ChildItem –Path $Src -file -Recurse | Where-Object {($_.LastWriteTime -lt (Get-Date).AddDays(-30))} | Remove-Item -Whatif

Folder.txt 上的內容

New Folder

New Folder(2)

嘗試使用:

$Src = "C:\Users\Asus\Documents\PowerShell\Folder.txt"
Get-ChildItem –Path (Get-Content $Src) -file -Recurse

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM