|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Apr 2008
Messaggi: 50
|
Script cancellazione cartelle dopo 30 giorni
Ciao,
qualcuno di voi è in grado di passarmi uno script che controlli tutte le sottocartelle di un percorso che gli do io e che cancelli una sottocartella nel caso sia stata creata 30 giorni fa? (senza controllare i file all'interno che possono avere date molto vecchie che andrebbero a sfasare il delete) Io purtroppo sono giorni che cerco di farlo funzionare ma sto combinando solo casini.... grazie |
|
|
|
|
|
#2 | |
|
Senior Member
Iscritto dal: Dec 2005
Città: Istanbul
Messaggi: 1817
|
Quote:
Codice:
find /path/to/folder -type d -ctime 30 | xargs -I % rm -rf "%" (se vuoi "30 O PIÙ" giorni fa, allora cambia il 30 in +30)
__________________
One of the conclusions that we reached was that the "object" need not be a primitive notion in a programming language; one can build objects and their behaviour from little more than assignable value cells and good old lambda expressions. —Guy Steele |
|
|
|
|
|
|
#3 | |
|
Member
Iscritto dal: Apr 2008
Messaggi: 50
|
ciao,
purtroppo non mi riconosce il comando... io ho questo: Codice:
'Objective: To Delete folders older than certain # of days.
'Created by: MAK
'Date Written: Jun 4, 2004
'Usage: DeleteOldFolder "\\Servername\d$\MSSQL\BACKUP\Replication\" "2"
'Usage: DeleteOldFolder "\\Servername1\Sharename\Replication\" "3"
On error resume next
if isnull(WScript.Arguments(0))=True or isnull(WScript.Arguments(1))=True or isnull(WScript.Arguments(2))=True then
msgbox "Usage: DeleteOldFolder" & "'\\Servername1\Sharename\Replication\' '3' '\\servername2\log\DeleteOldFolders.log'"
end if
Dim Directory
Dim Noofdays
Dim FSO
Dim FSO2
Dim LogFile
Dim Folderlist
Dim folders
Directory =WScript.Arguments(0)
Noofdays=cint(WScript.Arguments(1))
LogFile=WScript.Arguments(2)
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FSO2 = CreateObject("Scripting.FileSystemObject")
Set oFSO = CreateObject("Scripting.FilesyStemObject")
Set ofile = oFSO.createTextFile(LogFile, True)
ofile.writeline "DeleteOldFolders Started"
ofile.writeline now()
Set Folderlist = FSO.GetFolder(Directory)
Set folders = Folderlist.SubFolders
For Each d In Folders
' msgbox d.name
' msgbox d.size
' msgbox d.dateCreated
' msgbox d.dateLastModified
' msgbox d.dateLastAccessed
tempdirectory = Directory & d.name
'msgbox Noofdays
'msgbox datediff("d",d.dateCreated,now())
If datediff("d",d.dateCreated,now()) > Noofdays Then
if tempdirectory <> "1Old Backup" and tempdirectory <> "Modem dell" and tempdirectory <> "Script_Tools" then
FSO2.DeleteFolder(tempdirectory )
ofile.writeline cstr(now()) & " " & tempdirectory & " Delete Started"
if err.number <>0 then
ofile.writeline cstr(now()) & " " & Err.description
err.clear
else
ofile.writeline cstr(now()) & " " & tempdirectory & " has been deleted"
err.clear
end if
end if
' msgbox tempdirectory & " has been deleted"
End If
Next
'msgbox "Done"
ofile.writeline "DeleteOldFolders Completed"
ofile.writeline now()
che faccio partire con un bat : Quote:
|
|
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Oct 2004
Messaggi: 1945
|
|
|
|
|
|
|
#5 |
|
Senior Member
Iscritto dal: Nov 2002
Messaggi: 6619
|
Questo comando lo sto provando ma cancella solo il contenuto di una cartella vecchia di 30 giorni, non la cartella stessa..
Ultima modifica di Unrue : 09-05-2010 alle 11:18. |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 12:02.




















