0

ヘルプ!

200 GB の圧縮された .log ログファイルを含むフォルダーをスキャンし、584 日を超えるすべてのファイルを削除する必要があります。

私はこれを見つけて、そこに返信を残しましたが、それまでの間誰かが助けてくれるなら、ありがとう

http://social.technet.microsoft.com/Forums/en/ITCG/thread/793118fb-8345-4711-9710-9c3e485e6d89?prof=必須

乾杯

4

1 に答える 1

0

SevenZipSharp を使用します。最初に重要なデータをバックアップしてください:)

意味をなさないパスなどを読んで変更してください。

[Reflection.Assembly]::LoadFile("c:\lib\SevenZipSharp.dll")
[SevenZip.SevenZipExtractor]::SetLibraryPath("c:\lib\7z.dll")
$zipFiles = Get-ChildItem D:\zips\ -Filter "*.zip"
$oldDate = (get-date).AddDays(-584)

$zipFiles | % {
    $compressor = [SevenZip.SevenZipCompressor]("C:\")
    $compressor.ArchiveFormat = "zip"
    $extractor = [SevenZip.SevenZipExtractor]($_.FullName)
    $object = New-Object 'system.collections.generic.dictionary[int,string]'
    $extractor.ArchiveFileData | %{
        if ($_.LastWriteTime -lt $oldDate){
            #null index deletes the file
            $object.add($_.Index,"")
        }
        else {
            $object.add($_.Index,$_.FileName)
        }
    }
    $compressor.ModifyArchive($_.FullName,$object)
}
于 2012-07-30T18:31:56.783 に答える