Статьи и доки
Меню сайта





Категории каталога
WIN [1]
Виндоз
MySQL [3]
Заметки по MySQL
FreeBSD [14]
Всё по FreeBSD
Скрипты WINDOWS [3]


Форма входа


Поиск


Друзья сайта



Приветствую Вас, Гость · RSS 19.04.2024, 02:42
Главная » Статьи » Скрипты WINDOWS

Скрипт по удалению файлов старше 7 дней
Скрипт по удалению файлов старше 7 дней.

Скрипт на самом деле очень простой.
Все делается через файл FORFILES.exe. Взял его я в дистрибутиве Windows 2003 server. Можно скачать отсюда: http://rm-rf.ucoz.ru/load/skachat_forfiles_exe/7-1-0-14

Вот сам скрипт:

Code

@echo off
rem File : delete_7daysold.bat
rem Computer : PDC
rem Use : remove old archives
rem Date : 07.12.2009
rem Author : J.C.Sand
rem Changes : None

FORFILES /D -8 /P E:\BACKUP\SYSTEMSTATES\ /S /M *.bkf /C "cmd /c del @file | more"

E:\BACKUP\SYSTEMSTATES\ - директория в котрой хранятся архивы

Остальное можно прочитать в справке к FORFILES.EXE smile Она ниже:

Quote

FORFILES [/P pathname] [/M searchmask] [/S]
[/C command] [/D [+ | -] {dd.MM.yyyy | dd}]

Description:
Selects a file (or set of files) and executes a
command on that file. This is helpful for batch jobs.

Parameter List:
/P pathname Indicates the path to start searching.
The default folder is the current working
directory (.).

/M searchmask Searches files according to a searchmask.
The default searchmask is '*' .

/S Instructs forfiles to recurse into
subdirectories. Like "DIR /S".

/C command Indicates the command to execute for each file.
Command strings should be wrapped in double
quotes.

The default command is "cmd /c echo @file".

The following variables can be used in the
command string:
@file - returns the name of the file.
@fname - returns the file name without
extension.
@ext - returns only the extension of the
file.
@path - returns the full path of the file.
@relpath - returns the relative path of the
file.
@isdir - returns "TRUE" if a file type is
a directory, and "FALSE" for files.
@fsize - returns the size of the file in
bytes.
@fdate - returns the last modified date of the
file.
@ftime - returns the last modified time of the
file.

To include special characters in the command
line, use the hexadecimal code for the character
in 0xHH format (ex. 0x09 for tab). Internal
CMD.exe commands should be preceded with
"cmd /c".

/D date Selects files with a last modified date greater
than or equal to (+), or less than or equal to
(-), the specified date using the
"dd.MM.yyyy" format; or selects files with a
last modified date greater than or equal to (+)
the current date plus "dd" days, or less than or
equal to (-) the current date minus "dd" days. A
valid "dd" number of days can be any number in
the range of 0 - 32768.
"+" is taken as default sign if not specified.

/? Displays this help message.

Examples:
FORFILES /?
FORFILES
FORFILES /P C:\WINDOWS /S /M DNS*.*
FORFILES /S /M *.txt /C "cmd /c type @file | more"
FORFILES /P C:\ /S /M *.bat
FORFILES /D -30 /M *.exe
/C "cmd /c echo @path 0x09 was changed 30 days ago"
FORFILES /D 01.01.2001
/C "cmd /c echo @fname is new since Jan 1st 2001"
FORFILES /D +5.7.2010 /C "cmd /c echo @fname is new today"
FORFILES /M *.exe /D +1
FORFILES /S /M *.doc /C "cmd /c echo @fsize"
FORFILES /M *.txt /C "cmd /c if @isdir==FALSE notepad.exe @file"

Категория: Скрипты WINDOWS | Добавил: jsand (05.07.2010)
Просмотров: 7170 | Рейтинг: 5.0/2 |
Всего комментариев: 0
Имя *:
Email *:
Код *:
Сайт управляется системой uCoz