xtshainge
Goto Top

Creation Timestamp Löschskript

Hi alle zusammen,

Ich muss das löschskript für Dateien auf einem Netzlaufwerk von creation timestamp auf modificatin timestamp umändern.
Der sinn daran ist, dass die Dateien nach 7 Tagen auf dem Laufwerk gelöscht werden wobei nicht zählen soll wann die Datei erstellt wurde sondern wann sie zuletzt benutzt wurde.
BZW wann die auf dem Laufwerk gelangt ist.
Dazu habe ich folgendees in meiner Batch Datei :
for /d %%g in ("%1\*") do forfiles /P %%g /S /d -7 /c "cmd /c if @isdir==FALSE del /Q /F @File"
for /d %%g in ("%1\*") do forfiles /P %%g /S /d -7 /c "cmd /c if @isdir==FALSE del /Q /F /A:H @File"
for /d %%g in ("%1\*") do forfiles /P %%g /S /d -7 /c "cmd /c if @isdir==FALSE del /Q /F /A:S @File"

Content-Key: 371085

Url: https://administrator.de/contentid/371085

Printed on: April 25, 2024 at 00:04 o'clock

Member: sabines
sabines Apr 13, 2018 at 06:35:15 (UTC)
Goto Top
Moin,

teste mal:

Get-ChildItem Laufwerk\Pfad | ? { ($_.LastAccessTime -lt (Get-Date).AddDays(-7)) } | % { remove-item $_.Fullname }


Gruss
Member: XTshainge
XTshainge Apr 13, 2018 at 06:36:11 (UTC)
Goto Top
Danke.
Mitglied: 135950
135950 Apr 13, 2018 at 06:36:55 (UTC)
Goto Top
Ich seh da kein Problem
gci "c:\Ordner" -File | ?{$_.LastWriteTime -lt (get-date).Addays(-7)} | del -Force  
Gruß m.