Delete files timestamp
if have txt directory name , date eliminate modify script?
folder.txt
foldera 60
folderb 40
foreach ($path in (get-content "folders.txt")) {
get-childitem $path -recurse |
where-object { $_.creationtime -lt (get-date).adddays(-time) -and (!($_.psiscontainer))} |
remove-item -verbose | out-file .\myfile.txt
}
folder.txt
foldera 60
folderb 40
foreach ($path in (get-content "folders.txt")) {
get-childitem $path -recurse |
where-object { $_.creationtime -lt (get-date).adddays(-time) -and (!($_.psiscontainer))} |
remove-item -verbose | out-file .\myfile.txt
}
hithorelpoderoso,
please try script below:
$folders = import-csv -path .\folder.txt -header 'path','intervalindays' foreach ($folder in $folders) { get-childitem -path $folder.path -recurse | where-object {$_.creationtime -lt (get-date).adddays(-$($folder.intervalindays))} | remove-item -whatif }
if there else regarding issue, please feel free post back.
best regards,
anna wang
Windows Server > Windows PowerShell
Comments
Post a Comment