2014-12-04 77 views
0

我是新编写脚本。我需要帮助写一个脚本,我将详细介绍如下:使用脚本[.bat]检查文件扩展过期的文件

  1. 目前,我有4个文件夹:名为.pdf
    • 2个文件夹与.rar文件
  2. 2个文件夹
  3. 一个脚本文件。检查所有文件夹。
  4. 此脚本将通过扩展名(.pdf/.rar)进行搜索,并检查文件是否过期(如过期1天)。
  5. 通过向包含过期文件的文件的文件夹名称向PIC发送电子邮件提醒。
+0

因为我是新手,我试过的是将文件从一个文件夹移动到另一个文件夹,即所有 – Dominic 2014-12-04 09:55:45

回答

0

您可以使用FORFILES命令执行此操作。 (Type FORFILES /?for documentation)

:: Set this Variable to the command to email someone 
SET MAILER=echo mail user -s 
:: Set this variable to the number of days overdue to look for 
SET OVERDUE=1 
:: Set folder names here - these are relative to the current directory 
SET FOLDERS= "C:\temp\BLANK" "C:\TEMP\New Folder" 
:: Now loop through the folders 
FOR /f "tokens=*" %%G in ('dir /b /s /a:d %FOLDERS%') do (
    echo %%G 
    FORFILES /p "%%G" /s /d %OVERDUE% /c "cmd /c %MAILER% @file" 
    PAUSE 
    ) 
EXIT /b