0

我正在寻找一个批处理文件,它只显示文件夹中超过 30 分钟的文本文件。

有人能帮我吗?

4

2 回答 2

0

另一种选择是使用 XXcopy(在http://www.xxcopy.com免费供个人使用),它具有微小的粒度并且能够仅列出文件。

于 2013-09-03T15:34:11.233 回答
0
    @echo off
    setlocal
        set "t_dir=C:\testdir"

        set "Win32_D_path=%t_dir:\=\\%"


        for /f "skip=2 tokens=2 delims=,." %%W in ('wmic path Win32_Directory where name^="%Win32_D_path%" get CreationDate /Format:csv') do set "dir_c_date=%%W"

        set dir_YYYY=%dir_c_date:~0,4%
        set dir_MM=%dir_c_date:~4,2%
        set dir_DD=%dir_c_date:~6,2%
        set dir_HH=%dir_c_date:~8,2%
        set dir_min=%dir_c_date:~10,2%
        set dir_sec=%dir_c_date:~12,2%

        set leap_year=n
        set /a ly=dir_YYYY %% 1
        if %ly% EQU 0 ( set leap_year=y ) else ( goto :elyc)
        set /a ly=dir_YYYY %% 100
        if %ly% EQU 0 ( set leap_year=n ) else ( goto :elyc)
        set /a ly=dir_YYYY %% 400
        if %ly% EQU 0 ( set leap_year=y ) else ( goto :elyc)

        :elyc
        set m31=01,03,05,07,08,10,12
        set m30=04,06,09,11


        set /a target_min=(dir_min+30)%%60
        if %target_min% LSS 10 set target_min=0%target_min%
        set /a target_hour=(dir_HH+(dir_min+30)/60)%%24
        if %target_hour% LSS 10 set target_hour=0%target_hour%
        set /a th_r=(dir_HH+(dir_min+30)/60)/24
        echo days modulus: %th_r%
        if %th_r% GEQ 1 (
            for  %%M in (%m31%) do (
                if %dir_MM% EQU %%M if %dir_DD% EQU 31 set /a target_day=1 && set /a target_month=dir_MM +1
                if %dir_MM% EQU %%M if %dir_DD% LSS 31 set /a target_day=dir_DD+1 && set /a target_month=dir_MM
                goto :ecm
            )
            for  %%M in (%m30%) do (
                if %dir_MM% EQU %%M if %dir_DD% EQU 30 set /a target_day=1 && set /a target_month=dir_MM +1
                if %dir_MM% EQU %%M if %dir_DD% LSS 30 set /a target_day=dir_DD+1 && set /a target_month=dir_MM
                goto :ecm
            )

            if "%leap_year%" EQU "n" if %dir_MM% EQU 02 if %dir_DD% EQU 28  set /a target_day=1 && set /a target_month=dir_MM +1
            if "%leap_year%" EQU "n" if %dir_MM% EQU 02 if %dir_DD% LSS 28  set /a target_day=dir_DD+1 && set /a target_month=dir_MM
            if "%leap_year%" EQU "y" if %dir_MM% EQU 02 if %dir_DD% EQU 29  set /a target_day=1 && set /a target_month=dir_MM +1
            if "%leap_year%" EQU "y" if %dir_MM% EQU 02 if %dir_DD% LSS 29  set /a target_day=dir_DD+1 && set /a target_month=dir_MM
            goto :ecm

        )
        set /a target_day=dir_DD
        set /a target_month=dir_MM

        :ecm
        if %target_day% LSS 10 set target_day=0%target_day%
        if %target_month% LSS 10 set target_month=0%target_month%
        if %target_month% GTR 12 ( set /a target_year=dir_YYYY+1 ) else (set /a target_year=dir_YYYY)
if %target_month% GTR 12 set target_month=01


        set  target_date=%target_year%%target_month%%target_day%%target_hour%%target_min%%target_sec%
        echo target date: %target_date%
        setlocal enableDelayedExpansion
        for /f "delims=" %%F in ('dir /b /s /a:-d %t_dir%') do (
            set "c_file=%%F"
            set "w32c_file=!c_file:\=\\!"
            for /f "skip=2 tokens=2 delims=,." %%D in ('WMIC DATAFILE WHERE name^="!w32c_file!" get CreationDate /Format:csv') do (
                if "%%D" GTR "%target_date%"  echo !c_file!
            )
        )
        endlocal


    endlocal

没有经过大量测试并且需要WMIC

于 2013-09-03T15:00:15.943 回答