• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >DOS/BAT > 使用forfiles命令批量删除N天前文件

使用forfiles命令批量删除N天前文件

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了forfiles 多条命令,forfiles不是内部命令,forfiles命令,forfiles 删除文件夹,forfiles 定期备份等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

在整理手上几台SQL SERVER 2000的数据库备份时,一方面为了方便快速还原数据库,另外一方面为了备份冗余、备份方式统一(先备份到本地,然后收上磁带),将以前通过Symantec Backup Exec直接备份上带的作业改成了如下方式:
    Step 1: 通过数据库维护计划将备份生成在本地磁盘M,完整备份保留2天,事务日志备份保留3天

            M:\DB_BACKUP\FULL_BACKUP
            M:\DB_BACKUP\LOG_BACKUP

    Step 2:  备份完成后通过Symantec Backup Exec将备份文件收上磁带。
但是发现即使SQL SERVER 2000的数据库维护计划设置了删除几天前的备份文件,但是发现根本没有删除过期备份。于是只好使用dos命令来处理。刚开始想用forfiles命令,结果我搜索的时候,发现Windows 2000下没有forfiles命令,后来通过从第三方复制过来,发现Windows 2000下也可以使用forfiles(如果不借助于forfiles命令,直接用批处理命令完成这个,那简直痛苦死了)
关于forfiles命令的语法如下所示
 
C:\>forfiles /?
FORFILES [/P pathname] [/M searchmask] [/S]
         [/C command] [/D [+ | -] {yyyy-MM-dd | 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

您可能想查找下面的文章:

  • 使用forfiles命令批量删除N天前文件

相关文章

  • 实现两个文本同行交替输出的批处理代码
  • 使用批处理按要求批量删除文件夹方法汇总
  • WinXP自动开机登陆WoW bat实现
  • 批处理学习教程
  • 无法使用GHOST及避免出现A:\GHOSTERR.TXT的解决方法
  • 批处理入门手册之批处理常用DOS命令篇(md、rd、ren、move)
  • 使用批处理禁用(启用)组策略的代码
  • cmd del命令 文件删除
  • 使用dos批处理文件的意义与应用方法
  • Wmic 实例应用代码分享

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • 命令行删除带.的文件夹(畸形文件夹)
    • ftp自动下载文件脚本分享(ftp命令下载文件)
    • 批处理bat命令 获取当前盘符和当前目录和上级目录的代码
    • 酷狗去广告一键去除批处理代码
    • 批处理文件简介与编写第1/2页
    • Windows命令行bat批处理延迟sleep方法(批处理延时)
    • Windows使用bat批处理实现守护进程脚本分享
    • 纯脚本备份_还原驱动增强版附相关sleep.exe
    • 计算字符串的长度的多种解决方案集锦
    • FTP命令基本使用方法

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有