pondělí 5. března 2012

SCRIPT: Jak smazat adresáře starší 8 dnů dávkově

Jak smazat adresáře, které jsou starší 8 dnů z příkazového řádku ?
Není to zas až tak velký problém ...

Jak tedy na to?

forfiles /p "c:\temp" /c "cmd /c if @isdir==TRUE RMDIR /S /Q @path" /d -365


ZDROJ:
http://technet.microsoft.com/en-us/library/cc753551(WS.10).aspx

Příklad:
The example shown above:
forfiles /p c:\ /s /m *.* /c "cmd /c if @isdir==true echo @file is a directory"
does not work because the /m switch means the command will only display directories, which name contains "." . Also, the boolean values TRUE and FALSE used in the variables are CASE SENSITIVE as suggested but not outright stated in the Remarks section. Removing the /m switch and using true in ALL CAPS like this:

forfiles /p c:\ /s /c "cmd /c if @isdir==TRUE echo @file is a directory"

lets the command complete as desired

Žádné komentáře:

Okomentovat